I suspect the issue is the way the query parser works. The query phrase
"exampleof bug" will be parsed into a query for the tokens "exampleof" and
"bug" that are adjacent to each other. The issue is that you do not have
two such tokens, instead you have a token with the value "exampleof bug",
which is a single token with a space in it. According to Lucene, they are
not the same thing. You would need to create an analyzer that would create
the tokens "exampleof" and "bug".

Cheers,

Ivan


On Thu, Aug 21, 2014 at 8:47 AM, ben <[email protected]> wrote:

> Also meant to include this in the script.
>
> echo "query_string query using singe quote which does not match lucene
> query documentation"
> curl -XPOST "$url/$defaultIndex/example/_search?pretty=true" -d '
> {
>   "query": {
>     "query_string": {
>       "query": "name:''exampleof bug''"
>     }
>   }
> }
> '
>
> On Thursday, August 21, 2014 8:39:14 AM UTC-7, ben wrote:
>>
>> I have attached a short bash script to recreate the situation. I have a
>> fairly simple custom analyzer that I want to break on camel case so
>> lowercase is last. Using the _analyze endpoint I can see the token I am
>> searching for is generated by the analyzer, however searching for it with
>> query_string yields a different result that a term query. I put comments in
>> the script to explain in more detail.
>>
>> Thanks for any help!
>>
>> #!/bin/sh
>>
>> url="http://localhost:9200";
>> defaultIndex="example"
>>
>> echo "Start over...this will fail the first time the script is run since
>> the index will not exist"
>> curl -XDELETE "$url/$defaultIndex?refresh=true"
>>
>> echo "Create index with custom analyzer"
>> curl -XPUT "$url/$defaultIndex" -d '{
>>  "index": {
>>             "analysis": {
>> "filter": {
>> "my_worddelim": {
>> "type": "word_delimiter",
>> "split_on_case_change": true,
>> "preserve_original": true
>> }
>> },
>>                     "analyzer": {
>> "my_analyzer": {
>> "type":         "custom",
>> "char_filter":  [ "html_strip" ],
>> "tokenizer":    "keyword",
>> "filter":       [ "stop", "my_worddelim", "lowercase" ]
>> }
>>                     }
>>             }
>>     }
>> }'
>>
>> echo
>>
>> curl -XPUT "$url/$defaultIndex/example/_mapping" -d '{
>>     "example" : {
>>         "properties" : {
>>             "name": {
>>                 "type" : "multi_field",
>>                 "path": "just_name",
>>                 "fields" : {
>>                     "name": { "type": "string", "analyzer": "my_analyzer"
>> },
>>     "sample" : {"type" : "string", "index" : "not_analyzed" },
>>                     "sample_name" : {"type" : "string", "analyzer":
>> "my_analyzer" }
>>                 }
>>             }
>> }
>>     }
>> }'
>>
>> echo "Shows the lowercase token exampleofbug is generated"
>> curl -XGET "$url/$defaultIndex/_analyze?analyzer=my_analyzer&pretty=true"
>> -d 'ExampleOf Bug'
>>
>> echo "Post the document (haven't tried with non-bulk request)"
>> curl -XPOST "$url/$defaultIndex/example/_bulk?refresh=true" -d '
>> { "index" :  {"_index":"example","_type":"example","_id":"2169167","_
>> version_type":"internal","_timestamp":0} }
>> {"name":"ExampleOf Bug"}
>> '
>>
>> echo
>>
>> echo "query_string query is unable to find token in the name field even
>> though the path is just_name. i also tried escaping space per documentation
>> and it fails to parse"
>> curl -XPOST "$url/$defaultIndex/example/_search?pretty=true" -d '
>> {
>>   "query": {
>>     "query_string": {
>>       "query": "name:\"exampleof bug\""
>>     }
>>   }
>> }
>> '
>>
>> echo
>>
>> echo "Can successfully find token in name field that I was unable to find
>> with query_string"
>> curl -XPOST "$url/$defaultIndex/example/_search?pretty=true" -d '
>> {
>>   "query": {
>>     "term": {
>>       "name": "exampleof bug"
>>     }
>>   }
>> }
>> '
>>
>>
>>  --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elasticsearch/fb920c7a-dce5-4272-8b80-1f148e96f8ae%40googlegroups.com
> <https://groups.google.com/d/msgid/elasticsearch/fb920c7a-dce5-4272-8b80-1f148e96f8ae%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQACjqdmqZ5s5YoCXN8SsEZv0sbfi2rx-tWPWM9h17t-5w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to