I have a Django project that uses SOLR for indexing.
I'm trying to search for a substring using the Haystack SearchQuerySet class.
For example, when a user searches for the term โear,โ he should return a record with a field with the value: โSearch . โ As you can see, the โearโ is a SUBSTRATION of the โSearchโ . (obviously :))
In other words, in an ideal Django world, I would like something like:
SearchQuerySet().all().filter(some_field__contains_substring='ear')
In the haystack documentation for SearchQuerySet ( https://django-haystack.readthedocs.org/en/latest/searchqueryset_api.html#field-lookups ), he says that only the following FIELD LOOKUP types are supported:
- contains
- accurate
- gt, gte, lt, lte
- in
- Startswith
- Range
I tried to use __ contains , but it behaves exactly like __ exact , which searches for the exact word (whole word) in the sentence, not the substring of the word.
I got confused because this functionality is pretty simple, and I'm not sure if I missed something, or there is another way to approach this problem (using Regex or something like that).
thanks
Nahn
source share