Greg_4
(Greg-4)
March 7, 2013, 2:59pm
1
Hi,
is it possible to create a query for not existing field like missingFilter.
I use bool query with should clause to boost matching queries.
Example:
"bool" : {
"should" : [ {
"terms" : {
"devices" : [ "samsung" ],
"boost" : 5.0
}
}, {
"terms" : {
"devices" : [ "htc" ],
"boost" : 10.0
}
}
} ],
"minimum_should_match" : "1"
}
If "devices"-field does not exist in document, document should match
nevertheless.
Thanks.
Greg.
--
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 .
For more options, visit https://groups.google.com/groups/opt_out .
spinscale
(Alexander Reelsen)
March 8, 2013, 12:06pm
2
Hey
a possibility is to add a filtered query - containing an not + exists
filter - to your should clauses from the bool query like this:
{
"filtered" : {
"query" : { "match_all" : {} },
"filter" : {
"not" : {
"exists" : { "field" : "devices" }
}
}
}
}
See here for more:
Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.
When doing it this way, check for the scores of the matching document to
make sure you get the desired results.
--Alex
On Thu, Mar 7, 2013 at 3:59 PM, Greg linuxzwerg@gmail.com wrote:
Hi,
is it possible to create a query for not existing field like missingFilter.
I use bool query with should clause to boost matching queries.
Example:
"bool" : {
"should" : [ {
"terms" : {
"devices" : [ "samsung" ],
"boost" : 5.0
}
}, {
"terms" : {
"devices" : [ "htc" ],
"boost" : 10.0
}
}
} ],
"minimum_should_match" : "1"
}
If "devices"-field does not exist in document, document should match
nevertheless.
Thanks.
Greg.
--
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 .
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 .
For more options, visit https://groups.google.com/groups/opt_out .
Greg_4
(Greg-4)
March 9, 2013, 11:12am
3
Thanks, I have not come up with this idea
Greg.
On Friday, March 8, 2013 1:06:25 PM UTC+1, Alexander Reelsen wrote:
Hey
a possibility is to add a filtered query - containing an not + exists
filter - to your should clauses from the bool query like this:
{
"filtered" : {
"query" : { "match_all" : {} },
"filter" : {
"not" : {
"exists" : { "field" : "devices" }
}
}
}
}
See here for more:
Elasticsearch Platform — Find real-time answers at scale | Elastic
When doing it this way, check for the scores of the matching document to
make sure you get the desired results.
--Alex
On Thu, Mar 7, 2013 at 3:59 PM, Greg <linux...@gmail.com <javascript:>>wrote:
Hi,
is it possible to create a query for not existing field like
missingFilter.
I use bool query with should clause to boost matching queries.
Example:
"bool" : {
"should" : [ {
"terms" : {
"devices" : [ "samsung" ],
"boost" : 5.0
}
}, {
"terms" : {
"devices" : [ "htc" ],
"boost" : 10.0
}
}
} ],
"minimum_should_match" : "1"
}
If "devices"-field does not exist in document, document should match
nevertheless.
Thanks.
Greg.
--
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 elasticsearc...@googlegroups.com <javascript:>.
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 .
For more options, visit https://groups.google.com/groups/opt_out .