Perform a fielded search within the documents for which the ids are passed along with boost value. The search term and ids of the documents vary with each search request
The term must be searched within the documents for which the ids are passed, and score calculated based on the boost values specified for the document ids
The no of document ids passed can be in the magnitudes of a million
We tried the following queries, the response time is ~150 seconds and elastic search nodes run out of memory
query string:
{
"query_string" : {
"query" : "field1:elastic AND ( _id:( 10000 10001 10002 10003 10004 )^19 OR _id:( 10005 10006 10008 10009 10010 )^95 )",
"default_field" : "drugsourcedata"
}
}
bool query using filter
{
"bool" : {
"must" : {
"match" : {
"field1" : {
"query" : "elastic",
"type" : "boolean"
}
}
},
"filter" : {
"terms" : {
"_id" : [ "10000", "10001", "10002", "10003", "10004", "10005", "10006", "10008", "10009", "10010" ]
}
},
"should" : [ {
"terms" : {
"_id" : [ "10000", "10001", "10002", "10003", "10004" ]
}
}, {
"terms" : {
"_id" : [ "10005", "10006", "10008", "10009", "10010" ]
}
} ]
}
}
bool query using constant score
"bool" : {
"must" : [ {
"query_string" : {
"query" : "field1:elastic"
}
}, {
"dis_max" : {
"tie_breaker" : 0.0,
"boost" : 1.0,
"queries" : [ {
"terms" : {
"_id" : [ "10000", "10001", "10002", "10003", "10004" ],
"boost" : 99.0
}
}, {
"terms" : {
"_id" : [ "10005", "10006", "10008", "10009", "10010" ],
"boost" : 87.0
}
} ]
}
} ]
}
}
Please can any one suggest the best approach to formulate the query to elasticsearch