# Shingle filter to support sub phrase matching

**URL:** <https://discuss.elastic.co/t/shingle-filter-to-support-sub-phrase-matching/18820>\
**Category:** Elasticsearch\
**Created:** [July 23, 2014, 12:43pm UTC](https://discuss.elastic.co/t/shingle-filter-to-support-sub-phrase-matching/18820 "2014-07-23T12:43:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicktackes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nicktackes/32/1174_2.png) [@nicktackes](https://discuss.elastic.co/u/nicktackes)\
**Post date:** [July 23, 2014, 12:43pm UTC](https://discuss.elastic.co/t/shingle-filter-to-support-sub-phrase-matching/18820/1 "2014-07-23T12:43:25Z")

</div>

I have created a gist with an analyzer that uses filter shingle in attempt to match sub phrases.

For instance I have entries in the table with discrete phrases like  
EGFR  
Lung  
Cancer  
Lung Cancer

and I want to match these when searching the phrase 'EGFR related lung cancer

My expectation is that the multi word matches score higher than the single matches, for instance...

1. Lung Cancer
2. Lung
3. Cancer
4. EGFR

Additionally, I tried a standard analyzer match but this didnt yield the desired result either. One complicating aspect to this approach is that the min\_shingle\_size has to be 2 or more. How then would I be able to match single words like 'EGFR' or 'Lung'?

thanks

[https://gist.github.com/nicktackes/ffdbf22aba393efc2169.js](https://gist.github.com/nicktackes/ffdbf22aba393efc2169.js)

---

<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 6, 2017, 1:13am UTC](https://discuss.elastic.co/t/shingle-filter-to-support-sub-phrase-matching/18820/2 "2017-07-06T01:13:58Z")

</div>


