bennylope / elasticstack

:card_index: Configurable indexing and other extras for Haystack (with ElasticSearch biases)
BSD 2-Clause "Simplified" License
127 stars 31 forks source link

Add ngram search analyzer setting #15

Closed m3brown closed 8 years ago

m3brown commented 8 years ago

This is a rudimentary attempt at adding search_analyzer capability to elasticstack. This is specifically to workaround how haystack handles ngram searches, detailed in issue 1057.

What this PR does:

What this PR does NOT do:

It certainly wouldn't be hard to do the last three bullet points, but they weren't required for my needs.

bennylope commented 8 years ago

Thanks Mike!

What this PR does NOT do:

  • Allow overriding of search_analyzer for non-ngram fields
  • Allow overriding of individual ngram fields

It's been a while since I spent much time fiddling in this codebase, but you should be able to specify an analyzer for an individual ngram field using a custom field, as is.

m3brown commented 8 years ago

Thanks for the feedback. Analyzer has two facets: indexing and searching. In the case of ngram fields, we want to use a different analyzer for indexing and searching. By specifying a search_analyzer, the regular 'analyzer' field is still used for indexing. This is NOT something we can do with your current 'analyzer' implementation.

See here for background info: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-analyzer.html

bennylope commented 8 years ago

Ah, great. One question for you: have you been working from (and presumably using) your fork with all of the current commits? What Django version are you using it with?

There's ostensibly an error in a previously merged pull request (not packaged on PyPI) and I'd like to know whether it's causing any immediate problems before releasing an update.

m3brown commented 8 years ago

I'm using Python 2.6/Django 1.5 (I know, don't ask) and haven't seen any issues. Everything seems to be working fine, but FYI I have not yet put this into production.

bennylope commented 8 years ago

Bummer, but good for you - you'd not see any issues as it'd only affect Django 1.7+.