Hello,
I am a beginner with elasticsearch. I try to integrate it in my Laravel project. I use, at the moment ES v6.3, with the following mapping in my index;
$params = [
'index' => 'stocks',
'body' => [
'settings' => [
'number_of_shards' => 5,
'number_of_replicas' => 1,
'index.requests.cache.enable'=> true
],
'mappings' => [
'stocks' => [
'properties' => [
'location' => [
'type' => 'geo_point'
],
'tags' => [
'type' => 'keyword'
],
'created_at' => [
'type' => 'keyword'
],
'status' => [
'type' => 'integer'
],
'is_public' => [
'type' => 'integer'
],
'is_safe' => [
'type' => 'integer'
],
'progress' => [
'type' => 'integer'
]
]
]
]
]
];
When i try a search with the code below, the 'text search' and 'sort' work fine but only the last filter is applied: 'is_safe => 1'. I need, of course the 3 filters working. I try with many 'bool', 'must' and other ideas but with always the same result. Has anybody a solution for me? Thanks in advance.
$query2 = [
'track_total_hits'=> true,
'query'=> [
'bool'=> [
'must'=> [
'multi_match' => [
'query' => $query,
'fields' => [ 'title^5', 'content', 'tags' ],
'type'=> 'best_fields',
'operator'=> 'and',
'fuzziness'=> 'AUTO'
]
],
'filter'=> [
'term'=> [
'status'=> 1
],
'term'=> [
'is_public'=> 1
],
'term'=> [
'is_safe'=> 1
]
]
]
],
'track_scores'=> true,
'sort' => [
[
'created_at'=> [
'order'=> $sort_date
]
]
]
];