# Elastic search issues (Synonyms Issue)

**URL:** <https://discuss.elastic.co/t/elastic-search-issues-synonyms-issue/276750>\
**Category:** Elasticsearch\
**Created:** [June 23, 2021, 8:49am UTC](https://discuss.elastic.co/t/elastic-search-issues-synonyms-issue/276750 "2021-06-23T08:49:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![newbees](https://avatars.discourse-cdn.com/v4/letter/n/df705f/32.png) [@newbees](https://discuss.elastic.co/u/newbees)\
**Post date:** [June 23, 2021, 8:49am UTC](https://discuss.elastic.co/t/elastic-search-issues-synonyms-issue/276750/1 "2021-06-23T08:49:40Z")

</div>

Hi All

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

```auto
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.

```auto
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

```auto
POST /new-service-address-index/_analyze

{

"analyzer" : "my_analyzer",

"text" : "Apt"

}

```

output

```auto
{

"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.

```auto
GET new-service-address-index/_search

{

"query": {

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

}

}

```

output

```auto
{

"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 .

```auto

GET new-service-address-index/_search

{

"query": {

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

}

}

```

This is giving blank results..

```auto
{

"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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 21, 2021, 8:49am UTC](https://discuss.elastic.co/t/elastic-search-issues-synonyms-issue/276750/2 "2021-07-21T08:49:55Z")

</div>

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