Filter don't score at all.
So if you need to compute relevancy, you need to use queries.
--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr
Le 7 mars 2014 à 15:41:52, Isaac Hazan (isaac.yann.hazan@gmail.com) a écrit:
Thx a lot.
Why in the case of scoring query is better than filter?
Thx.
/Itzhak
From: elasticsearch@googlegroups.com [mailto:elasticsearch@googlegroups.com] On Behalf Of David Pilato
Sent: Friday, March 07, 2014 12:57 PM
To: elasticsearch@googlegroups.com
Subject: RE: Boolean query does not return expected data in Elasticsearch
As soon as you don't want to scoring but you want to find exact values, it's really better to use filter.
In short, if you are using a query and if you have the same query as a filter, take the filter.
Filters are cached. It means that the next time you will run this filter, whatever the query is (match all, match, …) the filter will already knows which documents matchs.
Somehow it sounds like the resultset but on a filter level.
It's perfectly fine to translate your query to:
curl -XGET "http://localhost:9200/_search" -d'
{
"filter": {
"and": {
"filters": [
{
"term": {
"os": "android"
}
}, {
"term": {
"phone": "nexus"
}
}
]
}
}
}'
--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr
Le 6 mars 2014 à 18:58:33, isaac hazan (isaac.yann.hazan@gmail.com) a écrit:
Thx David.
I’ve read a few times the differences between query and filter and I do not fully grasp the difference.
Here is my understanding, a filter is a post processing logic on the data set resulted by a query? Is this right? Why would that be faster?
It is pointed in the doc that it is faster because it can be cached? I am not sure I understand that either, what is cached?
Is it the result set that is being cached?
For example let’s say I have a query that does “select deviceId,App from Mobile where Os = “android” and phone = “nexus” .
First I don’t know what to put in the query and what in the filter. But I suspect you might say that we should put in the filter the where clause?
Now if the next query I do:
“select deviceId,App from Mobile where Os = “android” -> without the phone field
This query will give a larger data set than the first, will the filter of the first help here?
In other terms If I have query that change dynamically, how the filter helps?
Thx a lot in advance. This would be super useful if I can get a clear explanation, I didn’t get one so far L.
From: elasticsearch@googlegroups.com [mailto:elasticsearch@googlegroups.com] On Behalf Of David Pilato
Sent: Thursday, March 06, 2014 4:39 PM
To: elasticsearch@googlegroups.com
Subject: RE: Boolean query does not return expected data in Elasticsearch
I meant field values.
But sorry I did not notice your mapping at the end.
The query sounds good.
Could you check your current mapping?
curl -XGET 'http://localhost:9200/unique_app_install/_mapping?pretty
To answer to the other question, fastest way would be to use post filters and not queries as you probably don't need to score here.
--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr
Le 6 mars 2014 à 12:39:46, isaac hazan (isaac.yann.hazan@gmail.com) a écrit:
Thx David.
Sorry but I misunderstand(beginner in ES).
Do you mean that the field names have been fed into ES as lower case? Or the field values?
Is this because of the “not analyzed”?
Do I need to the “not analyzed” for a term query like I did?
Thx a lot in advance.
From: elasticsearch@googlegroups.com [mailto:elasticsearch@googlegroups.com] On Behalf Of David Pilato
Sent: Thursday, March 06, 2014 1:24 PM
To: elasticsearch@googlegroups.com
Subject: Re: Boolean query does not return expected data in Elasticsearch
Probably because of mapping.
Everything has been indexed in lowercase and split into tokens...
--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr
Le 6 mars 2014 à 12:22:24, Isaac Hazan (isaac.yann.hazan@gmail.com) a écrit:
I have the following document in Elasticsearch as reported by Kibana:
{"deviceId":"C1976429369BFE063ED8B3409DB7C7E7D87196D9","appId":"DisneyDigitalBooks.PlanesAdventureAlbum","ostype":"iOS"}
Why the following query does not return success?
[root@myvm elasticsearch-1.0.0]# curl -XGET 'http://localhost:9200/unique_app_install/_search?pretty=1' -d '
{
"query" : {
"bool" : {
"must" : [ {
"term" : {
"deviceId" : "C1976429369BFE063ED8B3409DB7C7E7D87196D9"
}
}, {
"term" : {
"appId" : "DisneyDigitalBooks.PlanesAdventureAlbum"
}
}, {
"term" : {
"ostype" : "iOS"
}
} ]
}
}
}'
Here is the response from Elasticsearch:
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}
As a side question, is this the fastest way to query the data in my case?
Thx in advance.
UPDATE: Could it be related to the fact that I used the following mapping for this index?
curl -XPOST localhost:9200/unique_app_install -d '{
"settings" : {
"number_of_shards" : 5
},
"mappings" : {
"sdk_sync" : {
"properties" : {
"deviceId" : { "type" : "string" , "index": "not_analyzed"},
"appId" : { "type" : "string" , "index": "not_analyzed"},
"ostype" : { "type" : "string" , "index": "not_analyzed"}
}
}
}
}'
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/8e0cd982-8597-4b43-ab77-6e9245592ac7%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to a topic in the Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elasticsearch/0_-C5jQeKOk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/etPan.53185add.649bb77c.7bfa%40MacBook-Air-de-David.local.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/00f101cf3930%24c346bc40%2449d434c0%24%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to a topic in the Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elasticsearch/0_-C5jQeKOk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/etPan.53188897.61574095.7bfa%40MacBook-Air-de-David.local.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/010901cf3965%24ad6b1530%2408413f90%24%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to a topic in the Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elasticsearch/0_-C5jQeKOk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/etPan.5319a605.6b8b4567.9291%40MacBook-Air-de-David.local.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/026101cf3a13%246219c780%24264d5680%24%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/etPan.5319e19f.79e2a9e3.9291%40MacBook-Air-de-David.local.
For more options, visit https://groups.google.com/d/optout.