Reputation: 8111
I want to extract the following sql query to elasticsearch.
Select *
from someTable
Where @timestamp < some_date and @timestamp >= some_other_date
and dst != '-'
And then do some aggregations on the returned documents. The aggregations part I have figured it out, and works perfectly. But I don't get the documents filtered properly. I tried the following query but I get doc's with dst = '-' which are in turns computed in the aggregations.
The query
"query": {
"bool": {
"must_not": {
"term": {
"dst": '-'
}
},
"filter":{
"range":{
"@timestamp":{
"gte":"a date",
"lt": "another date"
}
}
}
}
}
Am I doing something wrong. I set the size to 0 because I am using aggregations (not shown in here). Elasticsearch ver2.4 and python elasticsearch library.
I know it's not working because the aggregations results contain values from documents that dst is '-"
Upvotes: 0
Views: 1864
Reputation: 123
This field should not be analyzed, as it analyzer removes - char from field in index.
If you need this field to be analyzed for an other reason use multi-fields. https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-fields.html
Upvotes: 1