Skip to content

analyzer not being applied to search time #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
clintongormley opened this issue Apr 20, 2010 · 2 comments
Closed

analyzer not being applied to search time #144

clintongormley opened this issue Apr 20, 2010 · 2 comments

Comments

@clintongormley
Copy link
Contributor

Hiya

It may be something else, but it looks like the analyzer defined in the mapping is being applied at index time, but not at search time:

I'm trying to add a custom analyzer which will lowercase terms, but preserve them as the whole term, so eg ABC123 becomes the single term abc123

However, if I search for ABC123 I would expect it to be converted to a search for abc123, and this isn't happening. If I search for abc123 then I get the correct results:

curl -XPUT 'http://127.0.0.2:9200/foo/'  -d '
{
   "index" : {
      "analysis" : {
         "analyzer" : {
            "lc" : {
               "filter" : [
                  "lowercase"
               ],
               "tokenizer" : "keyword"
            }
         }
      }
   }
}
'
# {
#    "ok" : true,
#    "acknowledged" : true
# }


curl -XPUT 'http://127.0.0.2:9200/foo/bar/_mapping'  -d '
{
   "properties" : {
      "myfield" : {
         "type" : "string",
         "analyzer" : "lc"
      }
   }
}
'
# {
#    "ok" : true,
#    "acknowledged" : true
# }


curl -XPOST 'http://127.0.0.2:9200/foo/bar'  -d '
{
   "myfield" : "ABC123"
}
'
# {
#    "ok" : true,
#    "_index" : "foo",
#    "_id" : "f413800e-69bf-4ca6-a9bd-484e08a371cf",
#    "_type" : "bar"
# }


curl -XGET 'http://127.0.0.2:9200/foo/bar/_search'  -d '
{
   "query" : {
      "term" : {
         "myfield" : "ABC123"
      }
   }
}
'
# {
#    "hits" : {
#       "hits" : [],
#       "total" : 0
#    },
#    "_shards" : {
#       "failed" : 0,
#       "successful" : 5,
#       "total" : 5
#    }
# }


curl -XGET 'http://127.0.0.2:9200/foo/bar/_search'  -d '
{
   "query" : {
      "term" : {
         "myfield" : "abc123"
      }
   }
}
'
# {
#    "hits" : {
#       "hits" : [
#          {
#             "_source" : {
#                "myfield" : "ABC123"
#             },
#             "_index" : "foo",
#             "_id" : "f413800e-69bf-4ca6-a9bd-484e08a371cf",
#             "_type" : "bar"
#          }
#       ],
#       "total" : 1
#    },
#    "_shards" : {
#       "failed" : 0,
#       "successful" : 5,
#       "total" : 5
#    }
# }
@clintongormley
Copy link
Contributor Author

Doh of course - it would only be analyzed if passed in as a query string, not as a term.

closing

@kimchy
Copy link
Member

kimchy commented Apr 26, 2010

Yea, but note that there is the field query as well, which make things simpler than using the query_string query.

ClaudioMFreitas pushed a commit to ClaudioMFreitas/elasticsearch-1 that referenced this issue Nov 12, 2019
costin added a commit that referenced this issue Dec 6, 2022
cbuescher pushed a commit to cbuescher/elasticsearch that referenced this issue Oct 2, 2023
With this commit we remove all leftover references to trial timestamp
and replace it with the new name race timestamp.

Relates elastic#128
Relates elastic#143
Relates elastic#144
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants