I'm trying to query results similar to (totally new with ES):
$query = 'select * from promoter where (id_assigned_topic = ' . $id_topic . ' or id_topic_father = ' . $id_topic . ' or id_topic_grandfather = ' . $id_topic . ') and lower(name) like "%' . $search . '%" order by ranking DESC LIMIT ' . $limit_low . ',' . ($limit_high - $limit_low) . ';';
and I have built this search query for ElasticSearch:
$params = [
'index' => 'es_promoters',
'type' => 'data',
'from' => $limit_low,
'size' => ($limit_high - $limit_low),
'body' => [
"query"=> [
"bool"=> [
"must"=>[
"query_string" => [
"fields" => ["name"],
"query" => $search
],
"query_string" => [
"fields" => ["name"],
"query" => '"' . $search . '"'
],
"query_string" => [
"fields" => ["name"],
"query" => '*' . $search . '*'
],
],
"filter" =>[
"bool" => [
"should" => [
"term" => [ "id_assigned_topic" => $id_topic ],
"term" => [ "id_topic_father" => $id_topic ],
"term" => [ "id_topic_grandfather" => $id_topic ],
],
"minimum_should_match" => 1
]
]
]
],
]
];
If I remove everything from the "filter" part I get all the results to match the names, however I cannot do an OR between the topic_ids.
my questions would be:
how can I do an OR between the various topic_ids?
how do I sort the final results descending by ranking?