Can you boost a has_child query inside of a bool query? Here is my example.
There are multiple has_child queries each of which represent a collection
that contains documents.
Mapping
curl -XPUT 'http://localhost:9200/collection-test?pretty=true' -d '{
"settings" : {
"number_of_shards" : 1,
"number_of_replicas" : 0
},
"mappings" : {
"document": {
"properties": {
"bodyText": { "type": "string" }
}
},
"collection_item": {
"_parent": { "type": "document" },
"_all" : {"enabled" : false},
"properties": {
"collection_id": { "type": "integer", "index":
"not_analyzed" }
}
}
}
}'
Documents
curl -XPUT 'http://localhost:9200/collection-test/document/1' -d '{
"bodyText" : "Creativity is inteligence having fun - Albert Einstein"
}'
curl -XPUT 'http://localhost:9200/collection-test/document/2' -d '{
"bodyText" : "Anything one man can imagine, other men can make real. -
Jules Verne"
}'
curl -XPUT 'http://localhost:9200/collection-test/document/3' -d '{
"bodyText" : "Man will become better when you show him what he is like.
- Anton Chekhov"
}'
Collections
curl -XPOST localhost:9200/collection-test/collection_item/1?parent=1 -d '{
"collection_id" : "1" }'
curl -XPOST localhost:9200/collection-test/collection_item/2?parent=1 -d '{
"collection_id" : "2" }'
curl -XPOST localhost:9200/collection-test/collection_item/4?parent=2 -d '{
"collection_id" : "2" }'
Multiple Term and Multiple Collection Query
Note: running this query requires at least ES 0.20.2 to support
"score_type".
curl -XPOST localhost:9200/collection-test/document/_search?pretty=true -d
'{
"query" : {
"bool" : {
"should" : [
{
"term" : { "bodyText" : { "value" : "inteligence", "boost"
: 1.0 } }
},
{
"term" : { "bodyText" : { "value" : "anything", "boost" :
1.0 }}
},
{
"has_child" : {
"type" : "collection_item",
"score_type" : "sum",
"query" : {
"term" : {
"collection_id" : "1"
}
}
}
},
{
"has_child" : {
"type" : "collection_item",
"score_type" : "sum",
"query" : {
"term" : {
"collection_id" : "2"
}
}
}
}
],
"minimum_number_should_match" : 1
}
}
}'
--
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.