Hi everyone,
I have put together the following mapping for a Catalog of Items (using
nGrams):
"mappings":{
"item":{
"properties":{
"productName":{
"fields" : {
"partial":{ "search_analyzer":"full_name",
"index_analyzer":"partial_name", "type":"string" },
"partial_back":{ "search_analyzer":"full_name",
"index_analyzer":"partial_name_back", "type":"string" },
"partial_middle":{ "search_analyzer":"full_name",
"index_analyzer":"partial_middle_name", "type":"string" },
"productName":{ "type":"string", "analyzer":"full_name" }
},
"type":"multi_field"
},
"productID":{ "type":"string", "analyzer":"simple" },
"vendor":{ "type":"string", "analyzer":"simple" },
"productDescription":{ "type":"string", "analyzer":"full_name"}
}
}
},
"settings":{
"analysis":{
"filter":{
"name_ngrams":{ "side":"front", "max_gram":50, "min_gram":2,
"type":"edgeNGram" },
"name_ngrams_back":{ "side":"back", "max_gram":50,
"min_gram":2, "type":"edgeNGram" },
"name_middle_ngrams":{ "type":"nGram", "max_gram":50,
"min_gram":2 }
},
"analyzer":{
"full_name":{
"filter":[ "standard", "lowercase", "asciifolding" ],
"type":"custom",
"tokenizer":"standard"
},
"partial_name":{
"filter":[ "standard", "lowercase", "asciifolding",
"name_ngrams" ],
"type":"custom",
"tokenizer":"standard"
},
"partial_name_back":{
"filter":[ "standard", "lowercase", "asciifolding",
"name_ngrams_back" ],
"type":"custom",
"tokenizer":"standard"
},
"partial_middle_name":{
"filter":[ "standard", "lowercase", "asciifolding",
"name_middle_ngrams" ],
"type":"custom",
"tokenizer":"standard"
}
}
}
}
and then populated some data in it (like the following:)
================= Data Population
curl -XPUT 'http://localhost:9200/store/item/1?pretty=true' -d '
{
"productName":"XBox 360 2Gig",
"productID":"1",
"vendor":"Amazon",
"productDescription": "XBox uncofingure"
}
'
curl -XPUT 'http://localhost:9200/store/item/2?pretty=true' -d '
{
"productName":"XBox 360 2Gig",
"productID":"2",
"vendor":"Buy",
"productDescription": "XBox configured from Buy"
}
'
curl -XPUT 'http://localhost:9200/store/item/3?pretty=true' -d '
{
"productName":"XBox 360 2Gig",
"productID":"3",
"vendor":"BestBuy",
"productDescription": "XBox from Best Buy"
}
'
curl -XPUT 'http://localhost:9200/store/item/4?pretty=true' -d '
{
"productName":"XBox 4Gig",
"productID":"4",
"vendor":"Amazon",
"productDescription": "XBox from Amazon"
}
'
curl -XPUT 'http://localhost:9200/store/item/5?pretty=true' -d '
{
"productName":"ipad 32Gig",
"productID":"5",
"vendor":"BestBuy",
"productDescription": "ipad from Amazon"
}
'
As you notice I have duplicates in the productName.
I am struggling to put together a query that I can use for Autocomplete
(Search Suggestion) correctly (on the productName).
I will appreciate any suggestions.
Thanks,
Robert
--