# QueryBuilders.queryString(), more than one default field to search on

**URL:** <https://discuss.elastic.co/t/querybuilders-querystring-more-than-one-default-field-to-search-on/4174>\
**Category:** Elasticsearch\
**Created:** [March 31, 2011, 9:43am UTC](https://discuss.elastic.co/t/querybuilders-querystring-more-than-one-default-field-to-search-on/4174 "2011-03-31T09:43:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michel\_Conrad](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michel\_Conrad](https://discuss.elastic.co/u/Michel_Conrad)\
**Post date:** [March 31, 2011, 9:43am UTC](https://discuss.elastic.co/t/querybuilders-querystring-more-than-one-default-field-to-search-on/4174/1 "2011-03-31T09:43:30Z")

</div>

Hi,

When using a QueryStringQueryBuilder through  
QueryBuilders.queryString, is it be possible to include more than one  
default field to search on when using prefix fields?  
My use case would be by default to search on two default fields and if  
the user specfies a prefix field, to search on the field the user  
specified.  
I was wondering if there is a better solution to this problem than  
patching the query before giving it to the QueryBuilder?

Best,  
Michel

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [March 31, 2011, 3:53pm UTC](https://discuss.elastic.co/t/querybuilders-querystring-more-than-one-default-field-to-search-on/4174/2 "2011-03-31T15:53:31Z")

</div>

Yep, check QueryStringQueryBuilder#field method. It allows to add a field, and a field with boost. You can also control if dis\_max will be used using #useDisMax method.  
On Thursday, March 31, 2011 at 11:43 AM, Michel Conrad wrote:

> Hi,
> 
> When using a QueryStringQueryBuilder through  
> QueryBuilders.queryString, is it be possible to include more than one  
> default field to search on when using prefix fields?  
> My use case would be by default to search on two default fields and if  
> the user specfies a prefix field, to search on the field the user  
> specified.  
> I was wondering if there is a better solution to this problem than  
> patching the query before giving it to the QueryBuilder?
> 
> Best,  
> Michel

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 4:09am UTC](https://discuss.elastic.co/t/querybuilders-querystring-more-than-one-default-field-to-search-on/4174/3 "2017-07-06T04:09:04Z")

</div>

Closed on July 6, 2017, 4:09am UTC


