-
-
Save polyfractal/bce8e9ce47a96a24e693 to your computer and use it in GitHub Desktop.
ElasticSearch Mapping
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" | |
}, | |
"warehouse":{ | |
"type":"string", | |
"analyzer":"simple" | |
}, | |
"vendor":{ | |
"type":"string", | |
"analyzer":"simple" | |
}, | |
"productDescription":{ | |
"type":"string", | |
"analyzer":"full_name" | |
}, | |
"categories":{ | |
"type":"string", | |
"analyzer":"simple" | |
}, | |
"stockLevel":{ | |
"type":"integer", | |
"index":"not_analyzed" | |
}, | |
"cost":{ | |
"type":"float", | |
"index":"not_analyzed" | |
} | |
} | |
} | |
}, | |
"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" | |
} | |
} | |
} | |
} | |
} | |
/*-----------------Example query:----------------------*/ | |
{ | |
"size":20, | |
"from":0, | |
"sort":[ | |
"_score" | |
], | |
"query":{ | |
"filtered":{ | |
"query":{ | |
"bool":{ | |
"should":[ | |
{ | |
"text":{ | |
"productName":{ | |
"boost":5, | |
"query":"test query", | |
"type":"phrase" | |
} | |
} | |
}, | |
{ | |
"text":{ | |
"productName.partial":{ | |
"boost":1, | |
"query":"test query" | |
} | |
} | |
}, | |
{ | |
"text":{ | |
"productName.partial_middle":{ | |
"boost":1, | |
"query":"test query" | |
} | |
} | |
}, | |
{ | |
"text":{ | |
"productName.partial_back":{ | |
"boost":1, | |
"query":"test query" | |
} | |
} | |
} | |
] | |
} | |
}, | |
"filter":{ | |
"bool":{ | |
"must":[ | |
{ | |
"terms":{ | |
"warehouse":[ | |
"international", | |
"usa", | |
"aus", | |
"de" | |
] | |
} | |
}, | |
{ | |
"range":{ | |
"stockLevel":{ | |
"gt":"0" | |
} | |
} | |
} | |
] | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
starting ES 2.0 index_analyzer should be changed to "analyzer"