Answer the question
In order to leave comments, you need to log in
I can not make a request, I already broke my head. What am I doing wrong?
Hello. A bit of background...
There are courses Courses have a list of tags.
I make an index:
'mappings' => [
'properties' => [
'id' => [
'type' => 'integer',
],
'name' => [
'type' => 'text',
'analyzer' => 'course',
],
'format' => [
'type' => 'keyword',
'null_value' => '',
],
'tags' => [
'type' => 'nested',
'properties' => [
'id' => [
'type' => 'integer',
],
'name' => [
'type' => 'text',
'analyzer' => 'tags',
],
],
],
],
]
...
WHERE id IN(...) and (name like '...' or tags.name like '...');
'query' => [
'bool' => [
'must' => [
['terms' => ['id' => $options['course_ids']]],
],
'should' => [
['match' => [
'name' => ['query' => $searchable],
]],
['nested' => [
'path',
'query' => [
'bool' => [
'must' => [
['match' => ['tags.name' => ['query' => $searchable]]],
],
]
],
]],
],
],
],
Answer the question
In order to leave comments, you need to log in
I decided myself. Here is the answer if anyone is interested.
{
"query": {
"bool": {
"must": [
{
"terms": {
"id": [
111,
222,
333
]
}
},
{
"bool": {
"should": [
{
"match": {
"name": {
"query": "курс"
}
}
},
{
"nested": {
"path": "tags",
"query": {
"match": {
"tags.name": {
"query": "курс"
}
}
}
}
}
]
}
}
]
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question