Java query equal to given rest query?


(Sam-4) #1

Hi

how to construct java query equal to given rest query?

"filter" : {

        "not" : {

    "query" : {

            "query_string" : { "query" : “Account 1 OR Account 2 OR 

Account 3 OR Account 4…}

        }

        }

    }

please help me?


(Eric Jain) #2

See http://www.elasticsearch.org/guide/reference/java-api/query-dsl.html?

On May 8, 9:37 pm, sam mishra.sam...@gmail.com wrote:

Hi

how to construct java query equal to given rest query?

"filter" : {

        "not" : {

    "query" : {

            "query_string" : { "query" : “Account 1 OR Account 2 OR

Account 3 OR Account 4…}

        }

        }

    }

please help me?


(Ivan Brusic) #3

Much of the code uses the builder pattern, so look at the various
methods of the request classes. For the search request:

https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/action/search/SearchRequest.java

There are a few different ways at creating a SearchRequest. I like
using the static factory methods in the Requets class.

SearchRequest request =
org.elasticsearch.client.Requests.searchRequest(index).type(type)....

--
Ivan

On Tue, May 8, 2012 at 9:37 PM, sam mishra.sameek@gmail.com wrote:

Hi

how to construct java query equal to given rest query?

"filter" : {

        "not" : {

    "query" : {

            "query_string" : { "query" : “Account 1 OR Account 2 OR

Account 3 OR Account 4…}

        }

        }

    }

please help me?


(Ivan Brusic) #4

Oops, sorry, I misread your email (multi-tasking fail). You wanted to
know about constructing an actual query and not just executing.

Follow Eric's link. The builder pattern still applies. Look at the
various methods under org.elasticsearch.index.query.QueryBuilders.

--
Ivan

On Wed, May 9, 2012 at 10:05 AM, Ivan Brusic ivan@brusic.com wrote:

Much of the code uses the builder pattern, so look at the various
methods of the request classes. For the search request:

https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/action/search/SearchRequest.java

There are a few different ways at creating a SearchRequest. I like
using the static factory methods in the Requets class.

SearchRequest request =
org.elasticsearch.client.Requests.searchRequest(index).type(type)....

--
Ivan

On Tue, May 8, 2012 at 9:37 PM, sam mishra.sameek@gmail.com wrote:

Hi

how to construct java query equal to given rest query?

"filter" : {

        "not" : {

    "query" : {

            "query_string" : { "query" : “Account 1 OR Account 2 OR

Account 3 OR Account 4…}

        }

        }

    }

please help me?


(system) #5