# Snowball (expected) search

**URL:** <https://discuss.elastic.co/t/snowball-expected-search/11393>\
**Category:** Elasticsearch\
**Created:** [March 31, 2013, 2:58pm UTC](https://discuss.elastic.co/t/snowball-expected-search/11393 "2013-03-31T14:58:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarcusLongmuir](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@MarcusLongmuir](https://discuss.elastic.co/u/MarcusLongmuir)\
**Post date:** [March 31, 2013, 2:58pm UTC](https://discuss.elastic.co/t/snowball-expected-search/11393/1 "2013-03-31T14:58:48Z")

</div>

I've been investigating the snowball analyzer in an attempt to create a  
search function that works as most users would expect a search function to.

I know that this post could create a lot of conflicting replies, but lets  
dive right in.

I've added the following analyzer:

"snowballanalyzer" : {  
"type":"snowball",  
"language" : "English",  
"stopwords" : ""  
}

Lets say I index the following text in a field of a document:

"The quick brown fox jumps over the lazy dog".

I'd like the following queries to return the document:  
quick brown  
the quick brown  
jump fox  
foxes dogs

And the following queries to not return anything:  
quick red  
all quick brown

I'm using the Java API with the following code:

boolFilterBuilder.must(FilterBuilders.queryFilter(QueryBuilders.fieldQuery("Message",  
query)));

There aren't many tutorials or samples that provide examples of which  
queries will return which results. Hopefully someone can shed some light on  
how this generic search functionality can be achieved.

Thanks to anyone that replies.

--  
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:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [March 31, 2013, 3:04pm UTC](https://discuss.elastic.co/t/snowball-expected-search/11393/2 "2013-03-31T15:04:54Z")

</div>

You have used a filter, but where is the query? Please can you gist or  
post the whole Java code so we can see what you do?

Jörg

Am 31.03.13 16:58, schrieb marcuslongmuir:

> boolFilterBuilder.must(FilterBuilders.queryFilter(QueryBuilders.fieldQuery("Message",  
> query)));

--  
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:** ![MarcusLongmuir](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@MarcusLongmuir](https://discuss.elastic.co/u/MarcusLongmuir)\
**Post date:** [March 31, 2013, 3:55pm UTC](https://discuss.elastic.co/t/snowball-expected-search/11393/3 "2013-03-31T15:55:13Z")

</div>

The query variable is a string containing one of the examples I've posted  
above.

The implementation code is rather convoluted due to branching logic, but  
I'll post a condensed block.

String query = "quick brown";

BoolFilterBuilder boolFilterBuilder = FilterBuilders.boolFilter();

boolFilterBuilder.must(FilterBuilders.queryFilter(QueryBuilders.fieldQuery(  
"Message", query)));

SearchRequestBuilder searchRequestBuilder = client.prepareSearch("myindex")  
.setFilter(boolFilterBuilder)  
.setSearchType(SearchType.QUERY\_THEN\_FETCH)

--  
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:43am UTC](https://discuss.elastic.co/t/snowball-expected-search/11393/4 "2017-07-06T02:43:26Z")

</div>


