# Question about refining search

**URL:** <https://discuss.elastic.co/t/question-about-refining-search/8481>\
**Category:** Elasticsearch\
**Created:** [July 20, 2012, 10:49pm UTC](https://discuss.elastic.co/t/question-about-refining-search/8481 "2012-07-20T22:49:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Linton](https://avatars.discourse-cdn.com/v4/letter/l/71e660/32.png) [@Linton](https://discuss.elastic.co/u/Linton)\
**Post date:** [July 20, 2012, 10:49pm UTC](https://discuss.elastic.co/t/question-about-refining-search/8481/1 "2012-07-20T22:49:05Z")

</div>

Im trying to build some search capability that will be used in an mobile  
app. Being new to ES I'm having problems getting the correct search  
results.  
I'm storing text like:

"I am an iPhone developer. I am looking for work for the next year. I am  
willing to travel"  
"Experienced Oracle DBA, willing to travel for work. I have about 5 years  
experience in DBA.."

"I am the super duper developer with massive amounts of experience. Call me  
for all work."

When I do a search like "Iphone developer" I get all three matches back  
even though the second has Oracle and nothing to do with Iphone.

Here is my Index and mappings along with query

curl -XPUT localhost:9200/providing/ -d '  
{"index":  
{ "number\_of\_shards": 1,  
"analysis": {  
"filter": {  
"mynGram" : {"type": "nGram", "min\_gram": 2, "max\_gram":  
10}  
},  
"analyzer": { "my\_anal" : {  
"type":"custom",  
"tokenizer": "standard",  
"filter": ["lowercase","stop","mynGram"]  
}  
}  
}  
}  
}  
}'

curl -XPUT localhost:9200/providing/post\_prov/\_mapping -d '{  
"post\_prov" : {  
"index\_analyzer" : "my\_anal",  
"search\_analyzer" : "my\_anal",  
"properties" : {  
"descr": {"type":"string", "analyzer":"standard"}  
}  
}}'

My query is:

curl -XGET '[http://localhost:9200/providing/post\_prov/\_search?pretty=true](http://localhost:9200/providing/post_prov/_search?pretty=true)'  
-d '{ "query" : { "query\_string" : { "descr" : { "query" : "ipone  
developer" } } } }'

Any help would be appreciated, again I'm very new so if I've done something  
stupid, go easy on me

Thanks

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [July 20, 2012, 11:27pm UTC](https://discuss.elastic.co/t/question-about-refining-search/8481/2 "2012-07-20T23:27:51Z")

</div>

The default operator for a query\_string query is OR:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

Still not sure why the second document is being matched on, but try  
simpler analyzers first before optimizing with ngrams. Besides, with  
ngrams, it is often best to not apply an ngram analyzer on the search  
string against a field that has been analyzed since you might get  
false positives between query strings with the same prefix.

--  
Ivan

On Fri, Jul 20, 2012 at 3:49 PM, Linton [trlinton@gmail.com](mailto:trlinton@gmail.com) wrote:

> Im trying to build some search capability that will be used in an mobile  
> app. Being new to ES I'm having problems getting the correct search  
> results.  
> I'm storing text like:
> 
> "I am an iPhone developer. I am looking for work for the next year. I am  
> willing to travel"  
> "Experienced Oracle DBA, willing to travel for work. I have about 5 years  
> experience in DBA.."
> 
> "I am the super duper developer with massive amounts of experience. Call me  
> for all work."
> 
> When I do a search like "Iphone developer" I get all three matches back even  
> though the second has Oracle and nothing to do with Iphone.
> 
> Here is my Index and mappings along with query
> 
> curl -XPUT localhost:9200/providing/ -d '  
> {"index":  
> { "number\_of\_shards": 1,  
> "analysis": {  
> "filter": {  
> "mynGram" : {"type": "nGram", "min\_gram": 2, "max\_gram":  
> 10}  
> },  
> "analyzer": { "my\_anal" : {  
> "type":"custom",  
> "tokenizer": "standard",  
> "filter": ["lowercase","stop","mynGram"]  
> }  
> }  
> }  
> }  
> }  
> }'
> 
> curl -XPUT localhost:9200/providing/post\_prov/\_mapping -d '{  
> "post\_prov" : {  
> "index\_analyzer" : "my\_anal",  
> "search\_analyzer" : "my\_anal",  
> "properties" : {  
> "descr": {"type":"string", "analyzer":"standard"}  
> }  
> }}'
> 
> My query is:
> 
> curl -XGET '[http://localhost:9200/providing/post\_prov/\_search?pretty=true](http://localhost:9200/providing/post_prov/_search?pretty=true)'  
> -d '{ "query" : { "query\_string" : { "descr" : { "query" : "ipone developer"  
> } } } }'
> 
> Any help would be appreciated, again I'm very new so if I've done something  
> stupid, go easy on me
> 
> Thanks

---

<div class="post-metadata">

**Author:** ![Linton](https://avatars.discourse-cdn.com/v4/letter/l/71e660/32.png) [@Linton](https://discuss.elastic.co/u/Linton)\
**Post date:** [July 21, 2012, 1:49am UTC](https://discuss.elastic.co/t/question-about-refining-search/8481/3 "2012-07-21T01:49:58Z")

</div>

Thanks Ivan,

Is there anyway to "loosen" ,if you will, the default\_operator of "and".  
My match works but if I change my query to  
"looking for iphone developer" I only get one hit when I should get 2 based  
on the following 2 stored sentences:

"iPhone developer available for hire."  
"I am an iPhone developer. I am looking for work for the next year. I am  
willing to travel."

I have not simplified the analyzer. Would that help this issue?

On Friday, July 20, 2012 6:27:51 PM UTC-5, Ivan Brusic wrote:

> The default operator for a query\_string query is OR:
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/query-string-query.html)
> 
> Still not sure why the second document is being matched on, but try  
> simpler analyzers first before optimizing with ngrams. Besides, with  
> ngrams, it is often best to not apply an ngram analyzer on the search  
> string against a field that has been analyzed since you might get  
> false positives between query strings with the same prefix.
> 
> --  
> Ivan
> 
> On Fri, Jul 20, 2012 at 3:49 PM, Linton [trlinton@gmail.com](mailto:trlinton@gmail.com) wrote:
> 
> > Im trying to build some search capability that will be used in an mobile  
> > app. Being new to ES I'm having problems getting the correct search  
> > results.  
> > I'm storing text like:
> > 
> > "I am an iPhone developer. I am looking for work for the next year. I am  
> > willing to travel"  
> > "Experienced Oracle DBA, willing to travel for work. I have about 5  
> > years  
> > experience in DBA.."
> > 
> > "I am the super duper developer with massive amounts of experience. Call  
> > me  
> > for all work."
> > 
> > When I do a search like "Iphone developer" I get all three matches back  
> > even  
> > though the second has Oracle and nothing to do with Iphone.
> > 
> > Here is my Index and mappings along with query
> > 
> > curl -XPUT localhost:9200/providing/ -d '  
> > {"index":  
> > { "number\_of\_shards": 1,  
> > "analysis": {  
> > "filter": {  
> > "mynGram" : {"type": "nGram", "min\_gram": 2,  
> > "max\_gram":  
> > 10}  
> > },  
> > "analyzer": { "my\_anal" : {  
> > "type":"custom",  
> > "tokenizer": "standard",  
> > "filter": ["lowercase","stop","mynGram"]  
> > }  
> > }  
> > }  
> > }  
> > }  
> > }'
> > 
> > curl -XPUT localhost:9200/providing/post\_prov/\_mapping -d '{  
> > "post\_prov" : {  
> > "index\_analyzer" : "my\_anal",  
> > "search\_analyzer" : "my\_anal",  
> > "properties" : {  
> > "descr": {"type":"string", "analyzer":"standard"}  
> > }  
> > }}'
> > 
> > My query is:
> > 
> > curl -XGET '  
> > [http://localhost:9200/providing/post\_prov/\_search?pretty=true](http://localhost:9200/providing/post_prov/_search?pretty=true)'  
> > -d '{ "query" : { "query\_string" : { "descr" : { "query" : "ipone  
> > developer"  
> > } } } }'
> > 
> > Any help would be appreciated, again I'm very new so if I've done  
> > something  
> > stupid, go easy on me
> > 
> > Thanks

---

<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:19am UTC](https://discuss.elastic.co/t/question-about-refining-search/8481/4 "2017-07-06T03:19:35Z")

</div>


