Elastic search issues (Synonyms Issue)

Hi All

We have created a synonym file .. this file contains following contents

Create synonym.txt file.

apt, unit, apartment, Apt, Apartment, Unit

Southeast, SouthEast, se, SE, South East, southeast

Southwest, SouthWest, sw, SW, South West, southwest

South, S

riverside, 572, Riverside, River Side, RiverSide

We uploaded this is s3 bucket in aws
Create new index – new-service-address-index with the details shown below.

PUT new-service-address-index

{

"settings": {

"index": {

"analysis": {

"analyzer": {

"my_analyzer": {

"type": "custom",

"tokenizer": "standard",

"filter": ["my_filter"]

}

},

"filter": {

"my_filter": {

"type": "synonym",

"synonyms_path": "analyzers/F141926729",

"updateable": true

}

}

}

}

},

"mappings": {

"properties": {

"addressline1": {

"type": "text",

"analyzer": "standard",

"search_analyzer": "my_analyzer"

}

}

}

Tested the analyzer

POST /new-service-address-index/_analyze

{

"analyzer" : "my_analyzer",

"text" : "Apt"

}

output

{

"tokens" : [

{

"token" : "Apt",

"start_offset" : 0,

"end_offset" : 3,

"type" : "<ALPHANUM>",

"position" : 0

},

{

"token" : "apt",

"start_offset" : 0,

"end_offset" : 3,

"type" : "SYNONYM",

"position" : 0

},

{

"token" : "unit",

"start_offset" : 0,

"end_offset" : 3,

"type" : "SYNONYM",

"position" : 0

},

{

"token" : "apartment",

"start_offset" : 0,

"end_offset" : 3,

"type" : "SYNONYM",

"position" : 0

},

{

"token" : "Apartment",

"start_offset" : 0,

"end_offset" : 3,

"type" : "SYNONYM",

"position" : 0

},

{

"token" : "Unit",

"start_offset" : 0,

"end_offset" : 3,

"type" : "SYNONYM",

"position" : 0

}

]

}

Query and check whether the synonym is working.

GET new-service-address-index/_search

{

"query": {

"match": {"addressline1": "572"}

}

}

output

{

"took" : 4,

"timed_out" : false,

"_shards" : {

"total" : 5,

"successful" : 5,

"skipped" : 0,

"failed" : 0

},

"hits" : {

"total" : {

"value" : 20,

"relation" : "eq"

},

"max_score" : 10.625372,

"hits" : [

{

"_index" : "new-service-address-index",

"_type" : "_doc",

"_id" : "7",

"_score" : 10.625372,

"_source" : {

"addressline1" : "riverside",

"addressline2" : "xyz",

"city" : "Pune"

}

},

{

"_index" : "new-service-address-index",

"_type" : "_doc",

"_id" : "6",

"_score" : 9.384199,

"_source" : {

"addressline1" : "572 abc",

"addressline2" : "xyz",

"city" : "Pune"

}

},

{

"_index" : "new-service-address-index",

"_type" : "_doc",

"_id" : "5950760000",

"_score" : 8.519087,

"_source" : {

"premise_id" : "5950760000",

"addressline1" : "572 2ND AVE APT",

"addressline2" : " ",

"city" : "LAKE OSWEGO",

"county" : "CLACKAMAS",

"state" : "OR",

"postal" : "97034"

}

},

{

"_index" : "new-service-address-index",

"_type" : "_doc",

"_id" : "2256330000",

"_score" : 7.628208,

"_source" : {

"premise_id" : "2256330000",

"addressline1" : "3335 Riverside Dr S",

"addressline2" : " ",

"city" : "Salem",

"county" : "MARION",

"state" : "OR",

"postal" : "97306"

}

issue is Match_pharse_prefix is not working .



GET new-service-address-index/_search

{

"query": {

"match_phrase_prefix": {"addressline1": "572"}

}

}

This is giving blank results..

{

"took" : 1,

"timed_out" : false,

"_shards" : {

"total" : 5,

"successful" : 5,

"skipped" : 0,

"failed" : 0

},

"hits" : {

"total" : {

"value" : 0,

"relation" : "eq"

},

"max_score" : null,

"hits" : [ ]

}

}

Only match is working.

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