# NullPointerException with prefix query

**URL:** <https://discuss.elastic.co/t/nullpointerexception-with-prefix-query/9674>\
**Category:** Elasticsearch\
**Created:** [November 12, 2012, 2:32pm UTC](https://discuss.elastic.co/t/nullpointerexception-with-prefix-query/9674 "2012-11-12T14:32:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Benoit](https://avatars.discourse-cdn.com/v4/letter/b/5daacb/32.png) [@Benoit](https://discuss.elastic.co/u/Benoit)\
**Post date:** [November 12, 2012, 2:32pm UTC](https://discuss.elastic.co/t/nullpointerexception-with-prefix-query/9674/1 "2012-11-12T14:32:06Z")

</div>

I accidentally use boost syntax in a field of prefix query and got a  
NullPointerException.

When doing the same with match query i simply got an empty answer so i  
suppose the behavior is not normal.

Query and stack trace are in the following gist ...

> <https://gist.github.com/benoit-intrw/4059732>

Should i open an issue ?

Regards.

Benoît

--

---

<div class="post-metadata">

**Author:** ![Chris\_Male](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chris_male/32/2607_2.png) [@Chris\_Male](https://discuss.elastic.co/u/Chris_Male)\
**Post date:** [November 12, 2012, 10:32pm UTC](https://discuss.elastic.co/t/nullpointerexception-with-prefix-query/9674/2 "2012-11-12T22:32:36Z")

</div>

I think we could probably do some better validation here and provide a  
better error message. I do think you should open an issue.

On Tuesday, November 13, 2012 3:32:06 AM UTC+13, Benoît wrote:

> I accidentally use boost syntax in a field of prefix query and got a  
> NullPointerException.
> 
> When doing the same with match query i simply got an empty answer so i  
> suppose the behavior is not normal.
> 
> Query and stack trace are in the following gist ...  
> [NullPointerException with prefix query · GitHub](https://gist.github.com/4059732)
> 
> Should i open an issue ?
> 
> Regards.
> 
> Benoît

--

---

<div class="post-metadata">

**Author:** ![Benoit](https://avatars.discourse-cdn.com/v4/letter/b/5daacb/32.png) [@Benoit](https://discuss.elastic.co/u/Benoit)\
**Post date:** [November 14, 2012, 9:31am UTC](https://discuss.elastic.co/t/nullpointerexception-with-prefix-query/9674/3 "2012-11-14T09:31:58Z")

</div>

On Monday, November 12, 2012 11:32:36 PM UTC+1, Chris Male wrote:

> I think we could probably do some better validation here and provide a  
> better error message. I do think you should open an issue.

Done.

> <https://github.com/elastic/elasticsearch/issues/2408>
>
> I accidentally use boost syntax in a field of prefix query and got a NullPointer…Exception.
> 
> When doing the same with match query i simply got an empty answer so i suppose the behavior is not expected.
> 
> Query and stack trace are in the following gist ... https://gist.github.com/4059732
> 
> ES version is 0.19.10
> 
> Regards.
> 
> Benoît

--

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [November 14, 2012, 3:24pm UTC](https://discuss.elastic.co/t/nullpointerexception-with-prefix-query/9674/4 "2012-11-14T15:24:23Z")

</div>

By the way, '^' doesn't have the same effect in prefix queries as it does  
in the query\_string and multi\_match queries. The query in your example  
simply tries to search the field with a strange name "field^2". If you want  
to boost this query, use "boost":2.0 parameter instead.

On Wednesday, November 14, 2012 4:31:59 AM UTC-5, Benoît wrote:

> On Monday, November 12, 2012 11:32:36 PM UTC+1, Chris Male wrote:
> 
> > I think we could probably do some better validation here and provide a  
> > better error message. I do think you should open an issue.
> 
> Done.
> 
> [NullPointerException with prefix query · Issue #2408 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/2408)

--

---

<div class="post-metadata">

**Author:** ![Benoit](https://avatars.discourse-cdn.com/v4/letter/b/5daacb/32.png) [@Benoit](https://discuss.elastic.co/u/Benoit)\
**Post date:** [November 14, 2012, 4:27pm UTC](https://discuss.elastic.co/t/nullpointerexception-with-prefix-query/9674/5 "2012-11-14T16:27:38Z")

</div>

Hi,

On Wednesday, November 14, 2012 4:24:24 PM UTC+1, Igor Motov wrote:

> By the way, '^' doesn't have the same effect in prefix queries as it does  
> in the query\_string and multi\_match queries. The query in your example  
> simply tries to search the field with a strange name "field^2". If you want  
> to boost this query, use "boost":2.0 parameter instead.

Of course i noticed this.

I generate qdsl query from another syntax and got this error during  
development and so report it.

Thank you for your answers.

Benoît

--

---

<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, 3:04am UTC](https://discuss.elastic.co/t/nullpointerexception-with-prefix-query/9674/6 "2017-07-06T03:04:17Z")

</div>


