EsseTi
EsseTi

Reputation: 4271

Elastic search not giving results

I've been using ES for a while, but today is not working. I recreated my the docker-compose (can be smt there?), these are the data i've in ES:

edit: this is my input (here i've _source = False)

{'mappings': {'doc': {'_all': {'enabled': False}, 'dynamic': False, 'properties': {u'string': {'index': 'not_analyzed', 'type': 'string'}, '_time': {'index': 'not_analyzed', 'type': 'date'}, u'float': {'index': 'not_analyzed', 'type': 'float'}, u'datetime': {'index': 'not_analyzed', 'type': 'date'}, u'boolean': {'index': 'not_analyzed', 'type': 'boolean'}, u'integer': {'index': 'not_analyzed', 'type': 'long'}}, '_source': {'enabled': False}}}}

Schema:

{
  "07533744-b0e6-4a2f-8e94-1f7501589fee": {
    "aliases": {},
    "mappings": {
      "doc": {
        "dynamic": "false",
        "properties": {
          "_time": {
            "type": "date",
            "format": "strict_date_optional_time||epoch_millis"
          },
          "boolean": {
            "type": "boolean"
          },
          "datetime": {
            "type": "date",
            "format": "strict_date_optional_time||epoch_millis"
          },
          "float": {
            "type": "float"
          },
          "integer": {
            "type": "long"
          },
          "string": {
            "type": "string",
            "index": "not_analyzed"
          }
        }
      }
    },
    "settings": {
      "index": {
        "creation_date": "1465555846775",
        "number_of_shards": "5",
        "number_of_replicas": "1",
        "uuid": "-nZGMXbFRryraL0gPnr80g",
        "version": {
          "created": "2030399"
        }
      }
    },
    "warmers": {}
  }
}

Documents (some) with match_all query:

{
  "took": 15,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 10,
    "max_score": 1,
    "hits": [
      {
        "_index": "07533744-b0e6-4a2f-8e94-1f7501589fee",
        "_type": "doc",
        "_id": "49279857-84a7-4570-ad8e-9051079ca0ac",
        "_score": 1,
        "_source": {
          "doc": {
            "string": "1",
            "_time": "2016-06-10T12:50:59.509593",
            "float": 1.1,
            "datetime": "2016-06-10T12:50:59.497620",
            "boolean": false,
            "integer": 1
          }
        }
      },

now the query: {"query": {"bool": {"must": [{"match": {"integer": 1}}]}}}

returns

{
  "took": 4,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 0,
    "max_score": null,
    "hits": []
  }
}

any idea where the problem can be?

Edit: querying with curl curl -XGET -d '{"query": {"bool": {"must": [{"match": {"integer": 1}}]}}}' http://192.168.99.100:9200/07533744-b0e6-4a2f-8e94-1f7501589fee/doc/_search (no results)

curl -XGET -d '{"query": {"bool": {"must": [{"match": {"_id": "49279857-84a7-4570-ad8e-9051079ca0ac"}}]}}}' http://192.168.99.100:9200/07533744-b0e6-4a2f-8e94-1f7501589fee/doc/_search (gets a result)

Upvotes: 1

Views: 206

Answers (2)

Val
Val

Reputation: 217304

Try a term query instead:

{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "integer": 1
          }
        }
      ]
    }
  }
}

UPDATE

Note that your document doesn't comply to the mapping you're showing us.

    "_source": {
      "doc": {
        "string": "1",
        "_time": "2016-06-10T12:50:59.509593",
        "float": 1.1,
        "datetime": "2016-06-10T12:50:59.497620",
        "boolean": false,
        "integer": 1
      }
    }

should be like this, i.e. without the doc field.

    "_source": {
        "string": "1",
        "_time": "2016-06-10T12:50:59.509593",
        "float": 1.1,
        "datetime": "2016-06-10T12:50:59.497620",
        "boolean": false,
        "integer": 1

    }

Upvotes: 1

Sahil Gulati
Sahil Gulati

Reputation: 15141

Try the same query you want, but make a little change

GET 07533744-b0e6-4a2f-8e94-1f7501589fee/doc/_search
{
   "query": {
      "bool": {
         "should": [
            {
               "match": {
                  "doc.integer": 1
               }
            }
         ]
      }
   }
}

Use doc.integer instead of integer

Upvotes: 1

Related Questions