# Ngram and edgeNgram combined for \_all field; or different token filters per field for \_all

**URL:** <https://discuss.elastic.co/t/ngram-and-edgengram-combined-for--all-field-or-different-token-filters-per-field-for--all/13735>\
**Category:** Elasticsearch\
**Created:** [September 24, 2013, 11:41am UTC](https://discuss.elastic.co/t/ngram-and-edgengram-combined-for--all-field-or-different-token-filters-per-field-for--all/13735 "2013-09-24T11:41:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sebastian\_Kurfuerst](https://avatars.discourse-cdn.com/v4/letter/s/e79b87/32.png) [@Sebastian\_Kurfuerst](https://discuss.elastic.co/u/Sebastian_Kurfuerst)\
**Post date:** [September 24, 2013, 11:41am UTC](https://discuss.elastic.co/t/ngram-and-edgengram-combined-for--all-field-or-different-token-filters-per-field-for--all/13735/1 "2013-09-24T11:41:46Z")

</div>

Hey everybody,

(this is my first post to this list; let me start with saying ElasticSearch  
is a pleasure to work with; so thanks to everybody involved!)

I'm currently stuggeling with the question on how to build my index:  
Basically, I have a few fields which contain pretty short "human readable  
identifiers" which shall be searched.  
Because I have multiple fields per document containing such identifiers,  
I'm indexing them in the \_all property.

Currently, the \_all property is configured with the standard tokenizer, and  
the edge NGram token filter -- so people can search for partial words (from  
the start of the word) pretty well.  
Now, the requirement has arisen to also be able to find _any_ partial word,  
not just from the start of each word. However, if the start of the word  
matches, it should be _higher ranked_ than a match _inside_ the word.

Any thoughts on how to do that? I currently see different possibilities:

- can I somehow set different \_all indexing configurations for different  
fields? I.e. that the identifiers are indexed as multi\_field, once with  
edgeNgram and a higher boost, once with ngram and a lower boost. That'd be  
the solution I'd prefer, but from reading the docs I doubt that's possible.
- Can I somehow tell the system to use _both_ the edge ngram _and_ the  
ngram filter _in parallel_, such that the tokens starting from the  
beginning of every word are indexed _twice_ per document? This should, as I  
understand it, also result in a higher ranking, albeit it is somehow crude.
- Should I kick out the \_all field, manually concatenating the different  
strings on indexing time; indexing it once with edgeNgram and once with  
ngram; and then on _query time_ boost the _edgeNgram_ results over the  
other ones? (Would dislike this the most, as this effects every place where  
such queries are built...)

Thank you in advance for providing any advice,

Greets, Sebastian

--  
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/ngram-and-edgengram-combined-for--all-field-or-different-token-filters-per-field-for--all/13735/2 "2017-07-06T02:14:56Z")

</div>


