# How to set values at run time in ES addFilter

**URL:** <https://discuss.elastic.co/t/how-to-set-values-at-run-time-in-es-addfilter/10872>\
**Category:** Elasticsearch\
**Created:** [February 25, 2013, 5:41am UTC](https://discuss.elastic.co/t/how-to-set-values-at-run-time-in-es-addfilter/10872 "2013-02-25T05:41:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mukesh](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@mukesh](https://discuss.elastic.co/u/mukesh)\
**Post date:** [February 25, 2013, 5:41am UTC](https://discuss.elastic.co/t/how-to-set-values-at-run-time-in-es-addfilter/10872/1 "2013-02-25T05:41:41Z")

</div>

AndFilterBuilder queryFilters = FilterBuilders.andFilter();  
queryFilters.add(FilterBuilders.prefixFilter("Education", getZeducation()));  
log.debug(FilterBuilders.prefixFilter("Education", getZeducation()));  
queryFilters.add(FilterBuilders.prefixFilter("ResumeHeadline", getZresumeHeadline()));  
FilterBuilder aggFilter = FilterBuilders.andFilter(queryFilters);  
SearchResponse response = client.prepareSearch("resume\_index")  
.setSearchType(SearchType.DFS\_QUERY\_THEN\_FETCH)  
.setQuery(QueryBuilders.prefixQuery("Name",getZname()))  
.setFilter(aggFilter)  
.setFrom(10)  
.setSize(60)  
.setExplain(true)  
.execute()  
.actionGet();

Error:  
org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to execute phase [dfs], total failure; shardFailures {[W17rw9RHRyeEZGi-aBVlmQ][resume\_index][0]: SearchParseException[[resume\_index][0]: query[Name:szeducation=mcazresumeHeadline=asp\*],from[10],size[60]: Parse Failure [Failed to parse source [{"from":10,"size":60,"query":{"prefix":{"Name":"szeducation=mcazresumeHeadline=asp"}},"filter":{"and":{"filters":[{"and":{"filters":[{"prefix":{"Education":null}},{"prefix":{"ResumeHeadline":null}}]}}]}},"explain":true}]]]; nested: QueryParsingException[[resume\_index] No value specified for prefix filter]; }{[W17rw9RHRyeEZGi-aBVlmQ][resume\_index][2]: SearchParseException[[resume\_index][2]: query[Name:szeducation=mcazresumeHeadline=asp\*],from[10],size[60]: Parse Failure [Failed to parse source [{"from":10,"s

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 26, 2013, 7:14am UTC](https://discuss.elastic.co/t/how-to-set-values-at-run-time-in-es-addfilter/10872/2 "2013-02-26T07:14:21Z")

</div>

I don't know how many time I will have to repeat the same answer to your problem.  
Is there something you don't understand in my answer? If so, please tell me what.

My answer is always the same: don't provide null value to the prefixFilter.

Check **in your code** why getZname() is returning null.

HTH

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 25 févr. 2013 à 06:41, mukesh [mukeshp073@gmail.com](mailto:mukeshp073@gmail.com) a écrit :

AndFilterBuilder queryFilters = FilterBuilders.andFilter();  
queryFilters.add(FilterBuilders.prefixFilter("Education",  
getZeducation()));  
log.debug(FilterBuilders.prefixFilter("Education", getZeducation()));  
queryFilters.add(FilterBuilders.prefixFilter("ResumeHeadline",  
getZresumeHeadline()));  
FilterBuilder aggFilter = FilterBuilders.andFilter(queryFilters);  
SearchResponse response = client.prepareSearch("resume\_index")  
.setSearchType(SearchType.DFS\_QUERY\_THEN\_FETCH)  
.setQuery(QueryBuilders.prefixQuery("Name",getZname()))  
.setFilter(aggFilter)  
.setFrom(10)  
.setSize(60)  
.setExplain(true)  
.execute()  
.actionGet();

Error:  
org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to  
execute phase [dfs], total failure; shardFailures  
{[W17rw9RHRyeEZGi-aBVlmQ][resume\_index][0]:  
SearchParseException[[resume\_index][0]:  
query[Name:szeducation=mcazresumeHeadline=asp\*],from[10],size[60]: Parse  
Failure [Failed to parse source  
[{"from":10,"size":60,"query":{"prefix":{"Name":"szeducation=mcazresumeHeadline=asp"}},"filter":{"and":{"filters":[{"and":{"filters":[{"prefix":{"Education":null}},{"prefix":{"ResumeHeadline":null}}]}}]}},"explain":true}]]];  
nested: QueryParsingException[[resume\_index] No value specified for prefix  
filter]; }{[W17rw9RHRyeEZGi-aBVlmQ][resume\_index][2]:  
SearchParseException[[resume\_index][2]:  
query[Name:szeducation=mcazresumeHeadline=asp\*],from[10],size[60]: Parse  
Failure [Failed to parse source [{"from":10,"s

--  
View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/How-to-set-values-at-run-time-in-ES-addFilter-tp4030442.html](http://elasticsearch-users.115913.n3.nabble.com/How-to-set-values-at-run-time-in-ES-addFilter-tp4030442.html)  
Sent from the ElasticSearch Users mailing list archive at [Nabble.com](http://Nabble.com).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![mukesh](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@mukesh](https://discuss.elastic.co/u/mukesh)\
**Post date:** [February 26, 2013, 3:45pm UTC](https://discuss.elastic.co/t/how-to-set-values-at-run-time-in-es-addfilter/10872/3 "2013-02-26T15:45:19Z")

</div>

Thanks for reply .Problem now solved  
I had post both at same time..........

On Tue, Feb 26, 2013 at 12:44 PM, dadoonet [via Elasticsearch Users] \<  
[ml-node+s115913n4030520h61@n3.nabble.com](mailto:ml-node+s115913n4030520h61@n3.nabble.com)\> wrote:

> I don't know how many time I will have to repeat the same answer to your  
> problem.  
> Is there something you don't understand in my answer? If so, please tell  
> me what.
> 
> My answer is always the same: don't provide null value to the  
> prefixFilter.
> 
> Check **in your code** why getZname() is returning null.
> 
> HTH
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 25 févr. 2013 à 06:41, mukesh \<[hidden email][http://user/SendEmail.jtp?type=node&node=4030520&i=0](http://user/SendEmail.jtp?type=node&node=4030520&i=0)\>  
> a écrit :
> 
> AndFilterBuilder queryFilters = FilterBuilders.andFilter();  
> queryFilters.add(FilterBuilders.prefixFilter("Education",  
> getZeducation()));  
> log.debug(FilterBuilders.prefixFilter("Education",  
> getZeducation()));  
> queryFilters.add(FilterBuilders.prefixFilter("ResumeHeadline",  
> getZresumeHeadline()));  
> FilterBuilder aggFilter =  
> FilterBuilders.andFilter(queryFilters);  
> SearchResponse response = client.prepareSearch("resume\_index")
> 
> .setSearchType(SearchType.DFS\_QUERY\_THEN\_FETCH)
> 
> .setQuery(QueryBuilders.prefixQuery("Name",getZname()))  
> .setFilter(aggFilter)  
> .setFrom(10)  
> .setSize(60)  
> .setExplain(true)  
> .execute()  
> .actionGet();
> 
> Error:  
> org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to  
> execute phase [dfs], total failure; shardFailures  
> {[W17rw9RHRyeEZGi-aBVlmQ][resume\_index][0]:  
> SearchParseException[[resume\_index][0]:  
> query[Name:szeducation=mcazresumeHeadline=asp\*],from[10],size[60]: Parse  
> Failure [Failed to parse source  
> [{"from":10,"size":60,"query":{"prefix":{"Name":"szeducation=mcazresumeHeadline=asp"}},"filter":{"and":{"filters":[{"and":{"filters":[{"prefix":{"Education":null}},{"prefix":{"ResumeHeadline":null}}]}}]}},"explain":true}]]];
> 
> nested: QueryParsingException[[resume\_index] No value specified for prefix  
> filter]; }{[W17rw9RHRyeEZGi-aBVlmQ][resume\_index][2]:  
> SearchParseException[[resume\_index][2]:  
> query[Name:szeducation=mcazresumeHeadline=asp\*],from[10],size[60]: Parse  
> Failure [Failed to parse source [{"from":10,"s
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/How-to-set-values-at-run-time-in-ES-addFilter-tp4030442.html](http://elasticsearch-users.115913.n3.nabble.com/How-to-set-values-at-run-time-in-ES-addFilter-tp4030442.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [hidden email][http://user/SendEmail.jtp?type=node&node=4030520&i=1](http://user/SendEmail.jtp?type=node&node=4030520&i=1).
> 
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [hidden email][http://user/SendEmail.jtp?type=node&node=4030520&i=2](http://user/SendEmail.jtp?type=node&node=4030520&i=2).
> 
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> * * *
> 
> If you reply to this email, your message will be added to the discussion  
> below:
> 
> [http://elasticsearch-users.115913.n3.nabble.com/How-to-set-values-at-run-time-in-ES-addFilter-tp4030442p4030520.html](http://elasticsearch-users.115913.n3.nabble.com/How-to-set-values-at-run-time-in-ES-addFilter-tp4030442p4030520.html)  
> To unsubscribe from How to set values at run time in ES addFilter, click  
> here[http://elasticsearch-users.115913.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe\_by\_code&node=4030442&code=bXVrZXNocDA3M0BnbWFpbC5jb218NDAzMDQ0MnwtNjU5NDA5MjU2](http://elasticsearch-users.115913.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4030442&code=bXVrZXNocDA3M0BnbWFpbC5jb218NDAzMDQ0MnwtNjU5NDA5MjU2)  
> .  
> NAML[http://elasticsearch-users.115913.n3.nabble.com/template/NamlServlet.jtp?macro=macro\_viewer&id=instant\_html!nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify\_subscribers!nabble%3Aemail.naml-instant\_emails!nabble%3Aemail.naml-send\_instant\_email!nabble%3Aemail.naml](http://elasticsearch-users.115913.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml)

--  
[mukeshp073@gmail.com](mailto:mukeshp073@gmail.com)  
Laitkor.pvt ltd

---

<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, 2:49am UTC](https://discuss.elastic.co/t/how-to-set-values-at-run-time-in-es-addfilter/10872/4 "2017-07-06T02:49:27Z")

</div>

Closed on July 6, 2017, 2:49am UTC


