# Compounding a phrase and prefix

**URL:** <https://discuss.elastic.co/t/compounding-a-phrase-and-prefix/69226>\
**Category:** Elasticsearch\
**Created:** [December 16, 2016, 12:10am UTC](https://discuss.elastic.co/t/compounding-a-phrase-and-prefix/69226 "2016-12-16T00:10:45Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![daveharig](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daveharig/32/14030_2.png) [@daveharig](https://discuss.elastic.co/u/daveharig)\
**Post date:** [December 16, 2016, 12:10am UTC](https://discuss.elastic.co/t/compounding-a-phrase-and-prefix/69226/1 "2016-12-16T00:10:45Z")

</div>

Is it possible to compound phrase and prefix?

The user types in ‘Spring Mea’

Matching everything that has ‘Spring Mea’ in it like  
‘Spring Meadows’  
‘High Spring Meals'

vs.

just search for results that match directly ‘Spring Mea’

---

<div class="post-metadata">

**Author:** ![daveharig](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daveharig/32/14030_2.png) [@daveharig](https://discuss.elastic.co/u/daveharig)\
**Post date:** [December 20, 2016, 6:32pm UTC](https://discuss.elastic.co/t/compounding-a-phrase-and-prefix/69226/2 "2016-12-20T18:32:16Z")

</div>

Vibrant community!

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [December 20, 2016, 7:01pm UTC](https://discuss.elastic.co/t/compounding-a-phrase-and-prefix/69226/3 "2016-12-20T19:01:06Z")

</div>

Your bump actually worked!

[https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase-prefix.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase-prefix.html)

There are some caveats to how phrase prefix works in that it might not find all the results (`max_expansions`). Thus, the big block of text about autocomplete.

---

<div class="post-metadata">

**Author:** ![daveharig](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daveharig/32/14030_2.png) [@daveharig](https://discuss.elastic.co/u/daveharig)\
**Post date:** [December 20, 2016, 7:17pm UTC](https://discuss.elastic.co/t/compounding-a-phrase-and-prefix/69226/4 "2016-12-20T19:17:22Z")

</div>

🙌

---

<div class="post-metadata">

**Author:** ![daveharig](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daveharig/32/14030_2.png) [@daveharig](https://discuss.elastic.co/u/daveharig)\
**Post date:** [December 20, 2016, 7:32pm UTC](https://discuss.elastic.co/t/compounding-a-phrase-and-prefix/69226/5 "2016-12-20T19:32:30Z")

</div>

Any way to achieve full-text phrase and prefix with version 2.3? (current AWS service level)?

What parser does ES recommend?

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [December 20, 2016, 7:59pm UTC](https://discuss.elastic.co/t/compounding-a-phrase-and-prefix/69226/6 "2016-12-20T19:59:10Z")

</div>

In 2.3 you use a `match` query with `type` `phrase_prefix`:  
[https://www.elastic.co/guide/en/elasticsearch/reference/2.3/query-dsl-match-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.3/query-dsl-match-query.html)

What do you mean by "parser"? Do you mean `analzyer`? if so then usually you use the same one that you used when indexing. The default analyzer is pretty good. You can experiment with things like a [custom analyzer](https://www.elastic.co/guide/en/elasticsearch/reference/2.3/analysis-custom-analyzer.html) with [kstem](https://www.elastic.co/guide/en/elasticsearch/reference/2.3/analysis-kstem-tokenfilter.html) or some other token filter to get different stemming. [This](https://www.elastic.co/guide/en/elasticsearch/reference/2.3/analysis-lang-analyzer.html) contains a reference for how you'd build the built in analyzers which should give you a place to start customizing from.

---

<div class="post-metadata">

**Author:** ![daveharig](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daveharig/32/14030_2.png) [@daveharig](https://discuss.elastic.co/u/daveharig)\
**Post date:** [December 20, 2016, 8:34pm UTC](https://discuss.elastic.co/t/compounding-a-phrase-and-prefix/69226/7 "2016-12-20T20:34:50Z")

</div>

By parser I mean the difference between `lucene` and `dismax`

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [December 20, 2016, 9:31pm UTC](https://discuss.elastic.co/t/compounding-a-phrase-and-prefix/69226/8 "2016-12-20T21:31:43Z")

</div>

Do you have a link to the docs for the setting you are talking about?

---

<div class="post-metadata">

**Author:** ![daveharig](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daveharig/32/14030_2.png) [@daveharig](https://discuss.elastic.co/u/daveharig)\
**Post date:** [December 21, 2016, 1:52am UTC](https://discuss.elastic.co/t/compounding-a-phrase-and-prefix/69226/9 "2016-12-21T01:52:44Z")

</div>

Hi! No documentation. Our mobile app devs have only worked with "parsers" in the past for other search methods, but never ES. I think they are assuming ES must work with a parsers as well. Truthfully I don't think we understand the architecture. Anything you can offer to set us strait would be golden.

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [December 21, 2016, 1:01pm UTC](https://discuss.elastic.co/t/compounding-a-phrase-and-prefix/69226/10 "2016-12-21T13:01:01Z")

</div>

So `dismax` describes how you merge the weight from many fields so it more applies to the `multi_match` query. Here is what to read for that:  
[https://www.elastic.co/guide/en/elasticsearch/reference/2.3/query-dsl-multi-match-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.3/query-dsl-multi-match-query.html)

It is worth experimenting with, but if you need phrase prefix behavior you don't really have a choice. If you don't need the phrase prefix then `cross_fields` often gives the best results.

---

<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:** [January 18, 2017, 1:01pm UTC](https://discuss.elastic.co/t/compounding-a-phrase-and-prefix/69226/11 "2017-01-18T13:01:17Z")

</div>

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