# Information on how to define search queries?

**URL:** <https://discuss.elastic.co/t/information-on-how-to-define-search-queries/10998>\
**Category:** Elasticsearch\
**Created:** [March 4, 2013, 3:03pm UTC](https://discuss.elastic.co/t/information-on-how-to-define-search-queries/10998 "2013-03-04T15:03:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Per\_Ekman](https://avatars.discourse-cdn.com/v4/letter/p/e9bcb4/32.png) [@Per\_Ekman](https://discuss.elastic.co/u/Per_Ekman)\
**Post date:** [March 4, 2013, 3:03pm UTC](https://discuss.elastic.co/t/information-on-how-to-define-search-queries/10998/1 "2013-03-04T15:03:19Z")

</div>

Hi

I'm a little bit confused about the very basics of a search query and I  
would like to ask about some hints about it. I've been reading some basics  
here:

[http://lucene.apache.org/core/old\_versioned\_docs/versions/3\_5\_0/queryparsersyntax.html#Fields](http://lucene.apache.org/core/old_versioned_docs/versions/3_5_0/queryparsersyntax.html#Fields)

And then I've been running a few queries where I don't understand the  
results. So I've got an index with this data: "McDonalds" and "Mac-Donald".  
The index is analyzed using this analyzer:

```
                "ngram":{
                    "tokenizer":"whitespace",
                    "filter":[
                        "standard",
                        "lowercase",
                        "ngram",
                        "catenate_words"
                    ]
                },

```

....  
"ngram":{  
"type":"nGram",  
"min\_gram":3,  
"max\_gram":50  
},

So, I'm running three queries:

Query #1: "\_search?q=field1:%22mac%20don%22&pretty=true"  
Result: Mac-Donald

Query #2: "\_search?q=field1:%22mc%20don%22&pretty=true"  
Result: Mac-Donald, McDonald's

Query #3: "\_search?q=field1?q=companyLegalName:"don%20mac"&pretty=true"  
Result: None

My question is really: Is there any documentation that describes how these  
queries are run? Or can someone explain it?

My initial thought was that the first query searched on "mac" OR "don" in  
the field "field1" but after running these queries that thought doesn't  
hold up.

--  
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:** ![Per\_Ekman](https://avatars.discourse-cdn.com/v4/letter/p/e9bcb4/32.png) [@Per\_Ekman](https://discuss.elastic.co/u/Per_Ekman)\
**Post date:** [March 4, 2013, 3:15pm UTC](https://discuss.elastic.co/t/information-on-how-to-define-search-queries/10998/2 "2013-03-04T15:15:11Z")

</div>

I now realise that the "mac don" query is a search on the entire string,  
and what I was trying to do must be written like  
"\_search?q=field1:don%20field1:mac", though I'm not sure I understand the  
results completely anyway. And still, is there somewhere any documentation  
that covers this? Would be good to be able to reference to people that will  
use the search service

On Monday, March 4, 2013 4:03:19 PM UTC+1, Per Ekman wrote:

> Hi
> 
> I'm a little bit confused about the very basics of a search query and I  
> would like to ask about some hints about it. I've been reading some basics  
> here:
> 
> [Apache Lucene - Query Parser Syntax](http://lucene.apache.org/core/old_versioned_docs/versions/3_5_0/queryparsersyntax.html#Fields)
> 
> And then I've been running a few queries where I don't understand the  
> results. So I've got an index with this data: "McDonalds" and "Mac-Donald".  
> The index is analyzed using this analyzer:
> 
> ```
> "ngram":{
> "tokenizer":"whitespace",
> "filter":[
> "standard",
> "lowercase",
> "ngram",
> "catenate_words"
> ]
> },
> 
> ```
> 
> ....  
> "ngram":{  
> "type":"nGram",  
> "min\_gram":3,  
> "max\_gram":50  
> },
> 
> So, I'm running three queries:
> 
> Query #1: "\_search?q=field1:%22mac%20don%22&pretty=true"  
> Result: Mac-Donald
> 
> Query #2: "\_search?q=field1:%22mc%20don%22&pretty=true"  
> Result: Mac-Donald, McDonald's
> 
> Query #3: "\_search?q=field1?q=companyLegalName:"don%20mac"&pretty=true"  
> Result: None
> 
> My question is really: Is there any documentation that describes how these  
> queries are run? Or can someone explain it?
> 
> My initial thought was that the first query searched on "mac" OR "don" in  
> the field "field1" but after running these queries that thought doesn't  
> hold up.

--  
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:** ![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:48am UTC](https://discuss.elastic.co/t/information-on-how-to-define-search-queries/10998/3 "2017-07-06T02:48:34Z")

</div>


