# Elasticsearch suggest by middle words by making preserve\_position\_increments: false

**URL:** <https://discuss.elastic.co/t/elasticsearch-suggest-by-middle-words-by-making-preserve-position-increments-false/16145>\
**Category:** Elasticsearch\
**Created:** [March 4, 2014, 2:38pm UTC](https://discuss.elastic.co/t/elasticsearch-suggest-by-middle-words-by-making-preserve-position-increments-false/16145 "2014-03-04T14:38:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shamsul\_haque](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@shamsul\_haque](https://discuss.elastic.co/u/shamsul_haque)\
**Post date:** [March 4, 2014, 2:38pm UTC](https://discuss.elastic.co/t/elasticsearch-suggest-by-middle-words-by-making-preserve-position-increments-false/16145/1 "2014-03-04T14:38:30Z")

</div>

Hi,

I am trying to implement middle word search, as Completion Suggester doc[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters-completion.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters-completion.html) said,  
preserve\_position\_increments: if disabled and using stopword analyzer, you  
could get a string starting with 'the beatles', if you suggest for 'b'.

i am trying to implement same by providing below mapping:

curl -XPUT '[http://localhost:9200/sugg\_test/test/\_mapping](http://localhost:9200/sugg_test/test/_mapping)' -d '{ "test" : {  
"properties" : { "name" : { "type" : "string" }, "auto\_suggest" : { "type"  
: "completion", "index\_analyzer" : "simple", "search\_analyzer" : "stop",  
"preserve\_position\_increments" : false, "payloads" : true } } } }'

but it dosen't work. Please any body help me, where i am doing wrong.  
i know i can do the same by splitting the word and add them in input, but i  
want to implement it by mapping.

Thanks

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/632d683f-4950-4f16-81c5-eaeeb6039879%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/632d683f-4950-4f16-81c5-eaeeb6039879%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [March 5, 2014, 1:26pm UTC](https://discuss.elastic.co/t/elasticsearch-suggest-by-middle-words-by-making-preserve-position-increments-false/16145/2 "2014-03-05T13:26:34Z")

</div>

you're using the "simple" analyzer at index time, which means that it is  
indexing ["the","beatles"]. If you change it to use the "stop" analyzer at  
both search and index time then it should work.

clint

On 4 March 2014 15:38, Shams Haque [shams.hq@gmail.com](mailto:shams.hq@gmail.com) wrote:

> Hi,
> 
> I am trying to implement middle word search, as Completion Suggester doc[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters-completion.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters-completion.html) said,  
> preserve\_position\_increments: if disabled and using stopword analyzer, you  
> could get a string starting with 'the beatles', if you suggest for 'b'.
> 
> i am trying to implement same by providing below mapping:
> 
> curl -XPUT '[http://localhost:9200/sugg\_test/test/\_mapping](http://localhost:9200/sugg_test/test/_mapping)' -d '{ "test" :  
> { "properties" : { "name" : { "type" : "string" }, "auto\_suggest" : {  
> "type" : "completion", "index\_analyzer" : "simple", "search\_analyzer" :  
> "stop", "preserve\_position\_increments" : false, "payloads" : true } } } }'
> 
> but it dosen't work. Please any body help me, where i am doing wrong.  
> i know i can do the same by splitting the word and add them in input, but  
> i want to implement it by mapping.
> 
> Thanks
> 
> --  
> 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).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/632d683f-4950-4f16-81c5-eaeeb6039879%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/632d683f-4950-4f16-81c5-eaeeb6039879%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/632d683f-4950-4f16-81c5-eaeeb6039879%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/632d683f-4950-4f16-81c5-eaeeb6039879%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQqhAFoRUUaZYEDM\_L8hRtnCFk6pGWA2nFHHUtk2bJR1w%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQqhAFoRUUaZYEDM_L8hRtnCFk6pGWA2nFHHUtk2bJR1w%40mail.gmail.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, 1:45am UTC](https://discuss.elastic.co/t/elasticsearch-suggest-by-middle-words-by-making-preserve-position-increments-false/16145/3 "2017-07-06T01:45:33Z")

</div>


