I have created and index with 1 shard and have 999 documents for a type.
I am trying to implement a search as you type query which is not working as expected.
The fields in documents have almost similar data and I want to enable search for all fields.
I have value for field f4 in my type as "Proj1", "Proj2", "Proj3"...... till "Proj999" .
Example document (all documents have almost similar data except field f4 which has success values as mentioned above like "Proj1", "Proj2", "Proj3".....)
{
"_index": "myindex",
"_type": "mytype",
"_id": "42",
"_score": 1,
"_source": {
"f1": "396","f2": "125650","f3": "BH.1511AI.001",
"f4": "Proj1",
"f5": "BH.1511AI.001","f6": "","f7": "","f8": "","f9": "","f10": "","f11": "","f12": "","f13": "","f14": "","f15": "","f16": "09/05/16 | 01:02PM | User","deleted": "0"
}
}
When I try to do a search for "Proj1", using following query
{
"index": "myindex",
"type": "mytype",
"body": {
"query": {
"multi_match": {
"query": "proj1",
"type": "cross_fields",
"operator": "and",
"fields": "f*",
"analyzer":"standard"
}
}
}
}
I am getting documents like "Proj10", "Proj11","Proj12", "Proj100",......"Proj1",..... so on.
I wanted that "Proj1" should be returned first in the search response for query string "Proj1", but it doesn't.
I am using edgeNgram filter for indexing my documents which looks like (I am using php)
//analyzer
"myNGramAnalyzer" => [
"type" => "custom",
"char_filter" => ["html_strip"],
"tokenizer" => "standard",
"filter" => ["lowercase","standard","asciifolding","stop","snowball","ngram_filter"]
]
//filter settings
"filter" => [
"ngram_filter" => [
"type" => "edgeNGram",
"min_gram" => "2",
"max_gram" => "20"
]
]