Autocomplete from multiple fields


(Paddy Mahadeva) #1

Hi,

I have an Elasticsearch index that has documents with a field StringField1, StringField2, NumberField1 etc. I need to build an autocomplete functionality that searches on all the 3 fields.

ie.

if user inputs

pa

it should fetch all strings in the string fields that starts with pa.

if I search 99 it should fetch all values starting with 99.
I tried

{"query":{
"multi_match":{
"query":"A*",
"fields":["Last_Name", "LEAD_SOURCE"],
"type":"phrase_prefix"
}
}
}

But it does not give any hits.

How can i solve this?

Thanks
Paddy


(Paddy Mahadeva) #2

Finally I could Solve this with the below structure. Took some reading and googling

//			{
//				  "query": {
//				    "multi_match": {
//				      "query": "9920200",
//				      "fields": ["stringField1", "StringField2", "NumberField1",],
//				      "type" : "phrase_prefix"
//				    }
//				  }

// }


(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.