# Search based on Lucene Query Parser Syntax

**URL:** <https://discuss.elastic.co/t/search-based-on-lucene-query-parser-syntax/54389>\
**Category:** Elasticsearch\
**Created:** [June 30, 2016, 10:32am UTC](https://discuss.elastic.co/t/search-based-on-lucene-query-parser-syntax/54389 "2016-06-30T10:32:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![axelfelix](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@axelfelix](https://discuss.elastic.co/u/axelfelix)\
**Post date:** [June 30, 2016, 10:32am UTC](https://discuss.elastic.co/t/search-based-on-lucene-query-parser-syntax/54389/1 "2016-06-30T10:32:24Z")

</div>

hi all,

I made a post in Kibana section "Kibana search based on Lucene Query Parser Syntax" but I think elasticsearch section is more appropriate.

I try to understand better the behavior of a lucene search through kibana.

I'm aware about analyzer, tokenizer, filter ...

**An exemple:**

I have a field "test" and I look for "toto-tata.test.ok" value.

- If I do test:toto-tata.test.ok I don't get the result as expected.
- If I do test:"toto-tata.test.ok" I get the result as expected.

I know in lucene, "toto-tata.test.ok" is a Phrase.

So what represents toto-tata.test.ok without quote for lucene ? How kibana make the search on the field "test" when there is no quote for the search value ?

For information, my metafield \_all is disable. I have a default field, it is not the "test" field.

Thanks in advance.  
Alex

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [July 4, 2016, 8:22am UTC](https://discuss.elastic.co/t/search-based-on-lucene-query-parser-syntax/54389/2 "2016-07-04T08:22:00Z")

</div>

Hey,

if you want to understand how Elasticsearch/Lucene are doing tokenization and split your field values into single terms, you should take a look at the [analyze API](https://www.elastic.co/guide/en/elasticsearch/reference/2.3/indices-analyze.html), which shows you the terms that are stored in the inverted index. This helps a lot to understand how search works (especially in combination with synonyms and specific analyzers).

--Alex

---

<div class="post-metadata">

**Author:** ![axelfelix](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@axelfelix](https://discuss.elastic.co/u/axelfelix)\
**Post date:** [July 5, 2016, 7:37am UTC](https://discuss.elastic.co/t/search-based-on-lucene-query-parser-syntax/54389/3 "2016-07-05T07:37:31Z")

</div>

Hi thanks for your answer,

but as explain in my post:

> I'm aware about analyzer, tokenizer, filter ...

So I already know how my terms are stored and tokens associated with those terms.

The question is, I know when I make a request with a specific field like test:"toto-tata.test.ok" that "toto-tata.test.ok" is recognize as a phrase for lucene. But how is interpreted if I remove the quote ?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [July 5, 2016, 8:13am UTC](https://discuss.elastic.co/t/search-based-on-lucene-query-parser-syntax/54389/4 "2016-07-05T08:13:45Z")

</div>

Hey,

a bool query is created for each term, see [https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax)

Is that what you needed to know or is there another question hidden?

--Alex

---

<div class="post-metadata">

**Author:** ![axelfelix](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@axelfelix](https://discuss.elastic.co/u/axelfelix)\
**Post date:** [July 5, 2016, 8:44am UTC](https://discuss.elastic.co/t/search-based-on-lucene-query-parser-syntax/54389/5 "2016-07-05T08:44:24Z")

</div>

Hey,

I think I find the answer on your link:

> ```
> As mentioned in Query String Query, the default_field is searched for the
> search terms, but it is possible to specify other fields in the query syntax:
> 
> ```

> ```
> where the status field contains active
> status:active
> 
> ```

> ```
> where the title field contains quick or brown.
> If you omit the OR operator the default operator will be used
> title:(quick OR brown)
> title:(quick brown)
> 
> ```

> ```
> where the author field contains the exact phrase "john smith"
> author:"John Smith"
> 
> ```

So if I understand well, when I look for _author:"John Smith"_, I look for documents having exactly tokens **[John,Smith]**.

But if I look for _author:John Smith_, I look for documents having token **John OR Smith**.

Do you agree with this conclusion ?

Thanks in advance,  
Alex

**EDIT:** I made some tests but it doesn't work like that for my exemple.

I try to test:"toto-tata.test.ok", I get the same result than test:(toto-tata.test.ok) but totally different result than test:toto-tata.test.ok

---

<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 5, 2017, 10:38pm UTC](https://discuss.elastic.co/t/search-based-on-lucene-query-parser-syntax/54389/6 "2017-07-05T22:38:18Z")

</div>


