2

We recently integrated ElasticPress for WooCommerce, and did some improvements to it's code (via it's filters), but hit a few things that appears to be limitations of the ElasticSearch API. We've made mods to the queries sent to the elastic search engine when searching orders, so that the search term works as a partial search (much like the LIKE statement in SQL).

It works fine, except when there are special symbols in the query, like space, or the @ symbol. I've read that this could be avoided by escaping the special characters, but i had no luck doing that either.

I'm using the wildcard query, and i tried replacnig spaces with their escaped version, or even the ? token (which should match any single character). And no luck with that either.

This query works:

"query": {
    "wildcard": {
        "meta._billing_full_name.value": "*manish*"
    }
}

This does too

"query": {
    "wildcard": {
        "meta._billing_full_name.value": "*kumar*"
    }
}

This doesn't:

"query": {
    "wildcard": {
        "meta._billing_full_name.value": "*manish k*"
    }
}

By the way, we're using AWS ElasticSearch Service as a service provider. They're using an seriously outdated version of ElasticSearch (1.5.3 as far as i know), and i'm not sure if that could be one cause of the problems.

Thanks

8
  • What is the mapping of meta._billing_full_name.value. Is it analyzed string. Commented Jun 23, 2016 at 5:56
  • @Richa i'm not sure. I just installed the plugin, and indexed the site using ElasticPress. I think it doesn't generate any special thing. How should i check what's the mapping of that prop? Commented Jun 23, 2016 at 16:42
  • Use curl -XGET 'http://serverIp:9200/index_name/_mapping/' Commented Jun 24, 2016 at 4:54
  • This seems to be the mapping: https://paste2.org/09sEeE4D (Posting an external link to keep formatting). Commented Jun 24, 2016 at 6:41
  • 1
    Is this the complete mapping? Seems incomplete Commented Jun 24, 2016 at 6:50

1 Answer 1

3

According to the mapping shown by you value seems to be a multifield. It means it has been indexed both as analyzed and not_analyzed string.

For not_analyzed version of it, use following query:

"query": {
"wildcard": {
    "meta._billing_full_name.value.raw": "*manish k*"
  }
}

It should work now.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks @Richa this wasn't the actual implementation i used, but it helped me get in the right direction. I used the sortable field instead of raw because i wanted to do search in lowercase, and according to my research after your help, that kind of analyzed string works as if it was not_analyzed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.