java api elastic text search help

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

java api elastic text search help

steam
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.
Reply | Threaded
Open this post in threaded view
|

Re: java api elastic text search help

Karussell
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 <[hidden email]> 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.
Reply | Threaded
Open this post in threaded view
|

Re: java api elastic text search help

steam
Thanks for replying.
But what the best method to apply for normal "search box" ?
Can you give some example please ?
Reply | Threaded
Open this post in threaded view
|

Re: java api elastic text search help

MikeNereson
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.
Reply | Threaded
Open this post in threaded view
|

Re: java api elastic text search help

steam
Ok, i will try it. Thanks
: )

2012/2/7 MikeNereson [via ElasticSearch Users]
<[hidden email]>:

> 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