# Using match\_phrase\_prefix against a filtered/queried subset of my index to reduce max\_expressions requirements

**URL:** <https://discuss.elastic.co/t/using-match-phrase-prefix-against-a-filtered-queried-subset-of-my-index-to-reduce-max-expressions-requirements/13758>\
**Category:** Elasticsearch\
**Created:** [September 25, 2013, 8:58pm UTC](https://discuss.elastic.co/t/using-match-phrase-prefix-against-a-filtered-queried-subset-of-my-index-to-reduce-max-expressions-requirements/13758 "2013-09-25T20:58:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anthony\_Campagna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anthony_campagna/32/2079_2.png) [@Anthony\_Campagna](https://discuss.elastic.co/u/Anthony_Campagna)\
**Post date:** [September 25, 2013, 8:58pm UTC](https://discuss.elastic.co/t/using-match-phrase-prefix-against-a-filtered-queried-subset-of-my-index-to-reduce-max-expressions-requirements/13758/1 "2013-09-25T20:58:09Z")

</div>

_Goal:_ To seamlessly autocomplete addresses while utilizing synonyms.

I have tried to use a standard tokenizer (so that I can use synonyms for  
each word) and utilize a match\_phrase\_prefix but that gives me issues. Two  
examples:

- If I type in "500 m" or "500 ma" it will not return the result i'm  
looking for. This is because "madison" is far down the expressions list. I  
have to go up to around 750 max expressions in order to get this to work  
properly
- If I type in "500 madison a" it will return no results. This is because  
it can't get to "ave" within it's max expressions. I have to go up to  
around 7500 max expressions in order for this to work properly.

And that's just not a reasonable solution for autocomplete.

_Question:_ Is there a way to do a filter or preliminary query to get all  
results that start with 500. THEN use only the possible matches of that  
query for a match\_phrase\_prefix query? Meaning the demand for max  
expressions will be FAR lower.

Maybe there is a different way entirely to do this?  
Maybe there is a way to take position into account when calculating the  
phrase prefix possibilities?  
Maybe each number can be a "type" in my index? Would this mean that the  
phrase prefix possibilities would be less?

_Synonym Filter:_  
"synonym": {  
"type": "synonym",  
"synonyms\_path": "analysis/address\_syms.txt"  
}

_Analysis:_  
{  
"str\_index\_analyzer": {  
"tokenizer": "standard",  
"char\_filter": [  
"my\_filter"  
],  
"filter": [  
"lowercase",  
"synonym"  
]  
}  
}

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:14am UTC](https://discuss.elastic.co/t/using-match-phrase-prefix-against-a-filtered-queried-subset-of-my-index-to-reduce-max-expressions-requirements/13758/2 "2017-07-06T02:14:42Z")

</div>


