Java api elastic text search help

Hello,
Please help me construct by java api elastic text search.
I have search like

SearchRequestBuilder searchRequestBuilder = client.prepareSearch("items")
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);

QueryBuilder queryBuilder = boolQuery()
    	.should(termQuery("title", searchText))
    	.should(termQuery("description", searchText));
searchRequestBuilder.setQuery(queryBuilder);

when i put on searchText only one word its search well but if i put two words i dont get any result. Should i separate on searchText every word and append to termQuery? Or write something like QueryBuilders.queryString(“title:test or test2”) ?
Thanks to advise.

You can use the normal text query or the queryString query which you
have already mentioned and which supports more advanced features but
is probably not suited for normal "search box inputs".

Peter.

On 7 Feb., 20:49, steam grandebu...@gmail.com wrote:

Hello,
Please help me construct by java api elastic text search.
I have search like

SearchRequestBuilder searchRequestBuilder = client.prepareSearch("items")
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);

    QueryBuilder queryBuilder = boolQuery()
            .should(termQuery("title", searchText))
            .should(termQuery("description", searchText));
    searchRequestBuilder.setQuery(queryBuilder);

when i put on searchText only one word its search well but if i put two
words i dont get any result. Should i separate on searchText every word and
append to termQuery? Or write something like
QueryBuilders.queryString(“title:test or test2”) ?
Thanks to advise.

--
View this message in context:http://elasticsearch-users.115913.n3.nabble.com/java-api-elastic-text...
Sent from the Elasticsearch Users mailing list archive at Nabble.com.

Thanks for replying.
But what the best method to apply for normal "search box" ?
Can you give some example please ?

I am setting my analyzer to "simple"

QueryBuilder queryBuilder =
queryString(term)
.useDisMax(true)

.defaultOperator(QueryStringQueryBuilder.Operator.OR)
.analyzer("simple")
.addField("x",x")
.addField("x",x");

I don't know if simple is the correct analyzer to use, but look at the
changing your analyzer.

Ok, i will try it. Thanks
: )

2012/2/7 MikeNereson [via Elasticsearch Users]
ml-node+s115913n3724021h45@n3.nabble.com:

I am setting my analyzer to "simple"

QueryBuilder queryBuilder =
queryString(term)
.useDisMax(true)

.defaultOperator(QueryStringQueryBuilder.Operator.OR)
.analyzer("simple")
.addField("x",x")
.addField("x",x");

I don't know if simple is the correct analyzer to use, but look at the
changing your analyzer.


If you reply to this email, your message will be added to the discussion
below:
http://elasticsearch-users.115913.n3.nabble.com/java-api-elastic-text-search-help-tp3723672p3724021.html
To unsubscribe from java api elastic text search help, click here.
NAML