Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
How to convert/wrap a BooleanQuery to/in a BoolQueryBuilder object?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
bilash  
View profile  
 More options Aug 2 2012, 10:33 pm
From: bilash <ghkaw...@gmail.com>
Date: Thu, 2 Aug 2012 19:33:51 -0700 (PDT)
Local: Thurs, Aug 2 2012 10:33 pm
Subject: How to convert/wrap a BooleanQuery to/in a BoolQueryBuilder object?

My application creates BoolQueryBuilder objects using Java API. Now I need
to cache these in Jedis for reuse. Jedis only allows String type objects to
be stored in it. So I convert the BoolQueryBuilder objects to String
objects and store it. But how do I get BoolQueryBuilder objects back from
these String objects? An example String representation is:

{
  "bool" : {
    "must" : [ {
      "text" : {
        "levelCount" : {
          "query" : 1,
          "type" : "phrase"
        }
      }
    }, {
      "query_string" : {
        "query" : "\"I love New York\"",
        "fields" : [ "level_0" ],
        "default_operator" : "and",
        "analyzer" : "defaultAnalyzer",
        "phrase_slop" : 0
      }
    } ]
  }

}

I can convert this String to a BooleanQuery using QueryParser parse method.
But then how do I convert this BooleanQuery back to a BoolQueryBuilder? I
need a BoolQueryBuilder object because my SearchRequestBuilder expects a
builder object, not the query itself.

Any ideas?

Thanks in advance!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Igor Motov  
View profile  
 More options Aug 3 2012, 9:32 pm
From: Igor Motov <imo...@gmail.com>
Date: Fri, 3 Aug 2012 18:32:16 -0700 (PDT)
Local: Fri, Aug 3 2012 9:32 pm
Subject: Re: How to convert/wrap a BooleanQuery to/in a BoolQueryBuilder object?

Are you using some custom version
of SearchRequestBuilder? The standard SearchRequestBuilder object actually
accepts String as a query.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
bilash  
View profile  
 More options Aug 3 2012, 9:52 pm
From: bilash <ghkaw...@gmail.com>
Date: Fri, 3 Aug 2012 18:52:05 -0700 (PDT)
Local: Fri, Aug 3 2012 9:52 pm
Subject: Re: How to convert/wrap a BooleanQuery to/in a BoolQueryBuilder object?

Actually I am using prepareSearch which seems to only accept a QueryBuilder
objects as arguments. Is there a way I could pass a String query to
prepareSearch?

Here is how I am using it:

SearchRequestBuilder search = prepareSearch(query.getBoolQueryBuilder(),
query.getBoolFilterBuilder(), query.getSortBuilder());
SearchResponse response = search.execute().actionGet();

Here query is a custom query object that basically encapsulates a
BoolQueryBuilder. Is there any other way I could execute the above search
with a String query?

Thanks a lot for helping out.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Igor Motov  
View profile  
 More options Aug 3 2012, 10:23 pm
From: Igor Motov <imo...@gmail.com>
Date: Fri, 3 Aug 2012 19:23:26 -0700 (PDT)
Local: Fri, Aug 3 2012 10:23 pm
Subject: Re: How to convert/wrap a BooleanQuery to/in a BoolQueryBuilder object?

The prepareSearch function that you are referring to is probably your
internal function, correct? I am not sure how it's implemented and what
restrictions it has.

I meant something like this:

SearchResponse response
= client.prepareSearch("my-index").setQuery(query).setFilter(filter).addSort( sortBuilder).execute.actionGet();

Here query and filter can be Builders as well as Strings.

Igor


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
bilash  
View profile  
 More options Aug 3 2012, 10:26 pm
From: bilash <ghkaw...@gmail.com>
Date: Fri, 3 Aug 2012 19:26:20 -0700 (PDT)
Local: Fri, Aug 3 2012 10:26 pm
Subject: Re: How to convert/wrap a BooleanQuery to/in a BoolQueryBuilder object?

Yes, it is my own wrapper around Client.prepareSearch.

Thanks a lot for the help. I will try the String version/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »