Setting and mapping Looks:
{
"settings" : {
"analysis" : {
"analyzer" : {
"analyzer_startswith": {
"tokenizer": "keyword",
"filter": "lowercase"
}
}
}
"mappings" : {
"part" : {
"properties" : {
"partNumber" : {
"type" : "string",
"search_analyzer" : "standard",
"index_analyzer": "analyzer_startswith"
},
"crossReferencePartNumber" : {
"type" : "string",
"search_analyzer" : "standard",
"index_analyzer": "analyzer_startswith"
},
"commercialDescription_de_DE" : {
"type" : "string",
"search_analyzer" : "analyzer_startswith",
"index_analyzer": "standard"
},
"commercialDescription_en_US" : {
"type" : "string",
"search_analyzer" : "analyzer_startswith",
"index_analyzer": "standard"
}
}
}
}
}
with a search query:
{
"bool" : {
"should" : {
"match" : {
"_all" : {
"query" : "65",
"type" : "phrase_prefix",
"analyzer" : "standard",
"max_expansions" : 10
}
}
}
}
following results are provided:
{
"took" : 10,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 10,
"max_score" : null,
"hits" : [ {
"_index" : "test",
"_type" : "part",
"_id" : "281508_1",
"_score" : null,
"_source":{"partNumber":"10161515","crossReferencePartNumber":null,"commercialDescription_en_US":"HYDR.-ROHR 65X8 MM1000-6501","commercialDescription_de_DE":"HYDR.-ROHR 65X8 MM1000-6501"}
}, {
"_index" : "test",
"_type" : "part",
"_id" : "281508_5",
"_score" : null,
"_source":{"partNumber":"10161515","crossReferencePartNumber":null,"commercialDescription_en_US":"HYDR.-ROHR 65X8 MM1000-6501","commercialDescription_de_DE":"HYDR.-ROHR 65X8 MM1000-6501"}
}, {
"_index" : "test",
"_type" : "part",
"_id" : "280496_5",
"_score" : null,
"_source":{"partNumber":"10161599","crossReferencePartNumber":null,"commercialDescription_en_US":"HYDR.-ROHR 65X3X3390 T2+T3 BL5 MM800-6501","commercialDescription_de_DE":"HYDR.-ROHR 65X3X3390 T2+T3 BL5 MM800-6501"}
}, {
"_index" : "test",
"_type" : "part",
"_id" : "280496_1",
"_score" : null,
"_source":{"partNumber":"10161599","crossReferencePartNumber":null,"commercialDescription_en_US":"HYDR.-ROHR 65X3X3390 T2+T3 BL5 MM800-6501","commercialDescription_de_DE":"HYDR.-ROHR 65X3X3390 T2+T3 BL5 MM800-6501"}
}, {
"_index" : "test",
"_type" : "part",
"_id" : "266681_5",
"_score" : null,
"_source":{"partNumber":"10161808","crossReferencePartNumber":null,"commercialDescription_en_US":"HYDR.-ROHR 65X3.0 MM500-6501","commercialDescription_de_DE":"HYDR.-ROHR 65X3.0 MM500-6501"}
}, {
"_index" : "test",
"_type" : "part",
"_id" : "266681_1",
"_score" : null,
"_source":{"partNumber":"10161808","crossReferencePartNumber":null,"commercialDescription_en_US":"HYDR.-ROHR 65X3.0 MM500-6501","commercialDescription_de_DE":"HYDR.-ROHR 65X3.0 MM500-6501"}
}, {
"_index" : "test",
"_type" : "part",
"_id" : "284623_1",
"_score" : null,
"_source":{"partNumber":"10173433","crossReferencePartNumber":null,"commercialDescription_en_US":"HYDR.-ROHR 65X8.0 SPE10100-6501","commercialDescription_de_DE":"HYDR.-ROHR 65X8.0 SPE10100-6501"}
}, {
"_index" : "test",
"_type" : "part",
"_id" : "284623_5",
"_score" : null,
"_source":{"partNumber":"10173433","crossReferencePartNumber":null,"commercialDescription_en_US":"HYDR.-ROHR 65X8.0 SPE10100-6501","commercialDescription_de_DE":"HYDR.-ROHR 65X8.0 SPE10100-6501"}
}, {
"_index" : "test",
"_type" : "part",
"_id" : "410511_2",
"_score" : null,
"_source":{"partNumber":"6501","crossReferencePartNumber":["6501","LR501"],"commercialDescription_en_US":"3.990 dia locating ring Standard series","commercialDescription_de_DE":"3.990 dia locating ring Standard series"},
"highlight" : {
"partNumber" : [ "<b>6501</b>" ],
"crossReferencePartNumber" : [ "<b>6501</b>" ]
}
}, {
"_index" : "test",
"_type" : "part",
"_id" : "410527_2",
"_score" : null,
"_source":{"partNumber":"6501LN","crossReferencePartNumber":["6501 LN"],"commercialDescription_en_US":"3.990 dia locating ring LN series","commercialDescription_de_DE":"3.990 dia locating ring LN series"},
"highlight" : {
"partNumber" : [ "<b>6501LN</b>" ],
"crossReferencePartNumber" : [ "<b>6501</b> LN" ]
}
}
}
}
what needs to be changed in the setting or query to get records which starts with 65 first.
when we do search with prefix