How do I search words seperated by _ and . in ElasticSearch?

(Steve Bissett) #1

I am new to ElasticSearch and I am very happy with the speed at the moment. I still have one requirement that I haven't been able to achieve.

ElasticSearch seems to split the following text when doing indexing:


I am searching in Ruby like this using the ElasticSearch gem:

result = index: 'elasticsearch_dev',
                  body: {
                      query: {
                          "bool" => {
                            "must" => {"match" => {"search_text" => {"query" => "bmw", "operator" => "and"}}},
                            "must_not" => {"match" => {"search_text" => {"query" => "", "operator" => "or"}}}

What I'm trying to achieve:

When I search for bmw or, I want records with to match.

When I search for acboo or apple, I want records with apple_macbook_pro to match.

How do I go about achieving this?

Additional Info

I have looked at this site, which is along the lines of what I am looking to do, but not quite:

If I have the URL:

I want this to be tokenized as:

[uk, on, sale, com, uk-on, on-sale,,,, .com]

(Mark Walkom) #2

This is all about analysis with the various outputs that you want.
You may want to read through this chapter of the definitive guide to give you some context -

(system) #3