Issue for implementing analyzer


(Sam-4) #1

I configured analyzer in elasticsearch.yml with below define
configuration :
index :
analysis :
analyzer :
default :
tokenizer:lowercase

my json document contains:

{"id":"first","keyword":"robin"}
{"id":"second","keyword":"ROBIN"}
{"id":"Third","keyword":"robinson"}

After the setting I searched the string "r*" which gives me the doc
which contains robin ,ROBIN and robinson.

SearchResponse searchResponse = client.prepareSearch("test")
.setSearchType(SearchType.DEFAULT)
.setQuery(wildcardQuery("keyword","r*"))

Then I searched for "R*" This gave me the 0 hits.
when i search for "r*" ,this gave me the 3 hits.

Then I removed the setting from the yml file.
Again i am getting the same result.

Why i am not getting the result for the query "R*"?
in both cases, i am not using any setting for analyzer when preparing
the index.

Thanks


(Clinton Gormley) #2

Then I searched for "R*" This gave me the 0 hits.
when i search for "r*" ,this gave me the 3 hits.

The wildcard search is a term search - the text isn't passed through the
analyzer.

If you use a query_string or field search instead, then the text IS
passed through the analyzer, and by default lowercase_expanded_terms is
set to true, so your search will work

clint


(Sam-4) #3

thanks for quick reply.

i have some confusion regarding analyzer :

  1. analyzer work first then index is created or index is prepared then
    analyzer will works.
  2. if i am using explicit analyzer setting ,is it required to do some
    settings when index is prepared so that index uses the specified
    analyzer.

Thanks

On Jan 4, 4:58 pm, Clinton Gormley clin...@iannounce.co.uk wrote:

Then I searched for "R*" This gave me the 0 hits.
when i search for "r*" ,this gave me the 3 hits.

The wildcard search is a term search - the text isn't passed through the
analyzer.

If you use a query_string or field search instead, then the text IS
passed through the analyzer, and by default lowercase_expanded_terms is
set to true, so your search will work

clint


(Clinton Gormley) #4

i have some confusion regarding analyzer :

  1. analyzer work first then index is created or index is prepared then
    analyzer will works.

I don't understand this question, but: when you index text, the current
analyzer is used. If you change the current analyzer, the text that has
already been indexed won't change (until you reindex it).

When you search with a query string or field search, the same current
analyzer is applied

  1. if i am using explicit analyzer setting ,is it required to do some
    settings when index is prepared so that index uses the specified
    analyzer.

Yes, see:
http://www.elasticsearch.com/docs/elasticsearch/index_modules/analysis/

and to update the analyzer later:
http://www.elasticsearch.com/docs/elasticsearch/rest_api/admin/indices/update_settings/

clint


(system) #5