# Defining a list of strings as synonyms for a multiword string

**URL:** <https://discuss.elastic.co/t/defining-a-list-of-strings-as-synonyms-for-a-multiword-string/84669>\
**Category:** Elasticsearch\
**Created:** [May 5, 2017, 7:24am UTC](https://discuss.elastic.co/t/defining-a-list-of-strings-as-synonyms-for-a-multiword-string/84669 "2017-05-05T07:24:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jyoti\_Kumari1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jyoti_kumari1/32/17946_2.png) [@Jyoti\_Kumari1](https://discuss.elastic.co/u/Jyoti_Kumari1)\
**Post date:** [May 5, 2017, 7:24am UTC](https://discuss.elastic.co/t/defining-a-list-of-strings-as-synonyms-for-a-multiword-string/84669/1 "2017-05-05T07:24:42Z")

</div>

I want to provide variations of field "title" as its synonyms. I expect that if a user searches for the exact title or any of its variations, this particular document should be returned as first.

eg. I have many faq documents. one of those is  
 ![](https://us1.discourse-cdn.com/elastic/original/3X/9/d/9d98ac8a87b00a13a08152f3dbccdb5638b23218.png)

below is the required faq with its synonymous questions

 ![](https://us1.discourse-cdn.com/elastic/original/3X/d/f/dfac392ef61162c40784536a387779bde99b6d4a.png)  
I read about complexities that arise in case of multi word synonyms. Can anybody suggest how can I map all those question variations as equivalent to the actual question and referring to the same document.

One of the solutions that I though of as adding all ques variations as another property field in my index and while querrying using query more\_like\_this providing title(here it refers to actual title of question faq) and ques variations list.

below is my code for indexing, ingested data and querying  
PUT faq  
{  
"mappings": {  
"articles": {  
"properties": {  
"title": {  
"type": "string"  
},  
"ques\_var": {  
"type": "string"  
},  
"detail": {  
"type": "string"  
},  
"detail\_html": {  
"type": "string"  
},  
"account\_id": {  
"type": "long"  
}  
}  
}  
}  
}

Here my "title" would be "How to log in into facebook?"  
my "ques\_var" would be ["facebook login?", "where to login for facebook", "do i need to sign up for logging into facebook"]

and my query is like this below:

eq.query(Query.more\_like\_this([constants.TITLE, constants.QUES\_VAR], input\_data[  
constants.QUERY],  
min\_term\_freq=options.faq\_min\_term\_freq,  
min\_doc\_freq=options.faq\_min\_doc\_freq))

kindly suggest me if this approach is right

---

<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:** [June 2, 2017, 7:31am UTC](https://discuss.elastic.co/t/defining-a-list-of-strings-as-synonyms-for-a-multiword-string/84669/2 "2017-06-02T07:31:19Z")

</div>

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