ramz
(ram sailendra varma)
June 24, 2016, 7:10am
1
Hello,
Am trying to implement auto suggestion for mutli fields.
here's my mapping:
{
"bizz_suggest": {
"type": "completion",
"analyzer": "whitespace",
"search_analyzer":"whitespace",
"payloads": false,
"preserve_separators": true,
"preserve_position_increments": true,
"max_input_length": 50
},
"cat_suggest": {
"type": "completion",
"analyzer": "whitespace",
"search_analyzer":"whitespace",
"payloads": false,
"preserve_separators": true,
"preserve_position_increments": true,
"max_input_length": 50
}
}
bizz refers to Business Name
cat refers to Category Name
So, when trying to search basically suggester should return auto completion from both business and category.
I was able to achieve that for business, but how do i achieve suto suggestion for both the fields.
query:
"suggest" : {
"text" : "n",
"completion" : {
"field" : "bizz_suggest"
}
}
}
Is there a posiiblity to get suggester results from both category and auto suggest at a time?
thanks in advance.
regards,
Ram.
mvg
(Martijn Van Groningen)
June 24, 2016, 9:13am
2
I think you will need a second suggest field that contains the values from both fields. The completion suggestion works with a single field at the time. You could have the suggest queries in the same request via a bool query, but I think that isn't what you're looking for?
ramz
(ram sailendra varma)
June 24, 2016, 9:26am
3
Hi Martijn,
here's an example so that it explains what am exactly looking for:
document will be
{
"bizzName":"Huston",
"bizz_suggest": {
"weight": 30,
"input": [
"huston"
],
"output": "Huston - Hotel"
},
"cat_suggest": {
"weight": 30,
"input": [
"hotel"
],
"output": "Hotels"
}
}
Now when i type "h" it should return both Huston - Hotel and Hotels so that i can either select only the business or i would go for category.
Any idea how we implement this?
regards,
ramz
mvg
(Martijn Van Groningen)
June 24, 2016, 12:21pm
4
I don't see another way then adding another suggest field that contains both business and category names. For example by adding a general_suggest
field to your documents:
{
"bizzName": "Huston",
"bizz_suggest": {
"weight": 30,
"input": [
"new south wales"
],
"output": "Huston - Hotel"
},
"cat_suggest": {
"weight": 30,
"input": [
"hotel"
],
"output": "Hotels"
},
"general_suggest" : {
"input" : ["new south wales", "Hotels"]
}
}
ramz
(ram sailendra varma)
June 24, 2016, 12:47pm
5
Hi Martijn,
thanks for your reply.
i have resolved the issue, here's the query you need to send for auto suggest:
"text": "h",
"org_suggest": {
"completion": {
"field": "org_suggest",
"size" : "10"
}
},
"cat_suggest": {
"completion": {
"field": "cat_suggest",
"size" : "6"
}
}
}
regards,
Ram.
1 Like