Hello everyone,
I just registered on this forum and ask my first question.
I use aggregation to search a field "ID". The values of such field in the documents are those like "98.4325/D3452SD2", where "." and "/" are included. I expect that as long as I type something like "34.8765/D" in the search box, I wish that the top matching values, such as "34.8765/D3345", "34.8765/D2FD4D", ""34.8765/D567FFG", and so on will be returned back.
So I use "include" parameter to filter the result, but no matter the dot and forward slash are escaped or not, there is nothing returned back. The code shows below. Can anyone please advise how to solve this issue?
$params = [
'index' => $this->index,
'type' => '_doc',
'body' => [
'size' => 0,
'aggs' => [
$field => [
'terms' => [
'field' => $field,
'include' => '.' . strtolower(str_replace([".", "/"], [".", "/"], $string)) . '.|.' . strtoupper(str_replace([".", "/"], [".", "/"], $string)) . '.'
]
]
]
]
];
Thank you,