# Elasticsearch phrase mapping

**URL:** <https://discuss.elastic.co/t/elasticsearch-phrase-mapping/126871>\
**Category:** Elasticsearch\
**Created:** [April 5, 2018, 8:02am UTC](https://discuss.elastic.co/t/elasticsearch-phrase-mapping/126871 "2018-04-05T08:02:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hatemalimam](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hatemalimam/32/29602_2.png) [@hatemalimam](https://discuss.elastic.co/u/hatemalimam)\
**Post date:** [April 5, 2018, 8:02am UTC](https://discuss.elastic.co/t/elasticsearch-phrase-mapping/126871/1 "2018-04-05T08:02:33Z")

</div>

I have the following phrase:

> It's never happened to me – Messi Player of Barcelona to Cristiano Ronaldo star of Real  
> Madrid thanks Juve fans for ovation.

And a simple elasticsearch document called `Player`:

```
"firstName": {
   "localizedValues": {
      "de": "",
      "en": "Cristiano"
   }
},
"lastName": {
   "localizedValues": {
      "de": "",
      "en": "Ronaldo"
   }
}
"teamAssociations": [
   {
      "active": true,         
      "teamName": {
         "localizedValues": {
            "de": "",
            "en": "Real Madrid"
         }
      }
]

```

What I'm trying to do, is a simple mapping approach,  
Try to find a Player that plays for a team, in this case I would like to get Cristiano Ronaldo and Messi, and if a team in that phrase is found, then have that to boost the score for more relevance.

What I have tried so far:

```
{
    "query": {
        "bool": {
            "must": {
                "multi_match" : {
    			"query": " It's never happened to me – Messi to Cristiano Ronaldo star of Real Madrid thanks Juve fans for ovation ", 
    			"fields": ["firstName.localizedValues.*", "lastName.localizedValues.*", "teamAssociations.teamName.*^3"],
    			"type": "cross_fields",
    			"analyzer": "english"
			 }
            }
        }
    }
} 

```

But that gets also other players that plays for Read Madrid, which I don't want.  
Also in that title I might not have the team name, just players, so the team should be optional but important if found.

How can I approach this problem ?

Thanks in advance for the help.

---

<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:** [May 3, 2018, 8:02am UTC](https://discuss.elastic.co/t/elasticsearch-phrase-mapping/126871/2 "2018-05-03T08:02:48Z")

</div>

Closed on May 3, 2018, 8:02am UTC

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