allow to set a query using a string as well

This commit is contained in:
kimchy 2010-09-04 21:30:02 +03:00
parent 42b2e60af2
commit c050bb58da
2 changed files with 17 additions and 0 deletions

View File

@ -171,6 +171,14 @@ public class SearchRequestBuilder extends BaseRequestBuilder<SearchRequest, Sear
return this;
}
/**
* Constructs a new search source builder with a raw search query.
*/
public SearchRequestBuilder setQuery(String query) {
sourceBuilder().query(query);
return this;
}
/**
* Constructs a new search source builder with a raw search query.
*/

View File

@ -19,6 +19,7 @@
package org.elasticsearch.search.builder;
import org.elasticsearch.common.Unicode;
import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.common.io.FastByteArrayOutputStream;
import org.elasticsearch.common.trove.TObjectFloatHashMap;
@ -112,6 +113,14 @@ public class SearchSourceBuilder implements ToXContent {
return this;
}
/**
* Constructs a new search source builder with a raw search query.
*/
public SearchSourceBuilder query(String queryString) {
this.queryBinary = Unicode.fromStringAsBytes(queryString);
return this;
}
/**
* From index to start the search from. Defaults to <tt>0</tt>.
*/