Reputation: 7836
I have the following object in elastic.
Is there way to run a full text search query like: Fizz AND bar
{
"258": "Fizz buzz",
"12416": [
{
"161": 54,
"273": "text doc.txt",
"544": [
"text/plain"
],
"12290": "foo bar",
}
]
}
I've read about Runtime fields but it supports only keyword type and will work only in case of full match.
Upvotes: 1
Views: 370
Reputation: 9099
Query string will not work on nested field. You can either use a nested query or implement a custom _all field
PUT index117
{
"mappings": {
"properties": {
"_all":{
"type": "text"
},
"258":{
"type": "text",
"copy_to": "_all" --> copies data to _all field
},
"12416":{
"type": "nested",
"properties": {
"12290":{
"type":"text",
"copy_to": "_all"
}
}
}
}
}
}
POST index117/_doc
{
"258": "Fizz buzz",
"12416": [
{
"161": 54,
"273": "text doc.txt",
"544": [
"text/plain"
],
"12290": "foo bar"
}
]
}
GET index117/_search
{
"query": {
"query_string": {
"default_field": "_all",
"query": "foo AND bar"
}
}
}
Upvotes: 2