18👍
Note: The following solution is Solr 1.4 (and above) specific!
For more flexibility, I would recommend indexing your data with the NGramTokenizerFactory to do complete front and back wildcard searches. If you just want to search for substrings at the beginning or end of the string, consider using the EdgeNGramTokenizerFactory.
Here’s a drop in replacement of the text field type which would accomodate your need:
<fieldType name="text" class="solr.TextField" >
<analyzer type="index">
<tokenizer class="solr.NGramTokenizerFactory" minGramSize="3" maxGramSize="15" />
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.WhitespaceTokenizerFactory" />
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
- [Django]-Django – using of related_name in ManyToMany and in ForeignKey
- [Django]-Django: what is the difference (rel & field)
- [Django]-Is there a function for generating settings.SECRET_KEY in django?
4👍
When I’ve used
<tokenizer class="solr.NGramTokenizerFactory" minGramSize="3" maxGramSize="15" />
for making wildcard search from Brian’s answer, Solr indexing time dramaticly increased. In more than 20 times!
The other decision of wildcard searching problem I found here:
http://www.lucidimagination.com/blog/2009/09/08/auto-suggest-from-popular-queries-using-edgengrams/
You need just add filter
<filter class="solr.EdgeNGramFilterFactory" minGramSize="1" maxGramSize="25" />
(default tokenizer – solr.WhitespaceTokenizerFactory in index block of FieldType). For me result was the same with less system costs.
- [Django]-Receive a Base64 encoded image in Django Rest Framework and save into ImageField
- [Django]-Django admin – make all fields readonly
- [Django]-How to restart Celery gracefully without delaying tasks
1👍
A different approach, if you are having trouble with a small set of words, would be to use the solr.SynonymFilterFactory
http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters#solr.SynonymFilterFactory
You just have to maintain a simple text file that contains synonyms:
chick peep chicken
dawg hound dog
moggie puss kitten cat
Plurals should take care of themselves with other filters.
- [Django]-Nginx uwsgi (104: Connection reset by peer) while reading response header from upstream
- [Django]-Why does Django's signal handling use weak references for callbacks by default?
- [Django]-Django_debug_toolbar and Docker
0👍
I haven’t changed any configuration. I am just using star in front and in the back of my searchString: *chicke * (without white space at the end -> it’s because of SO formatting word as italic if you use * at the beginning and at the end)
- [Django]-Import "rest_framework" could not be resolved. But I have installed djangorestframework, I don't know what is going wrong
- [Django]-Django.db.utils.IntegrityError: duplicate key value violates unique constraint "django_content_type_pkey"
- [Django]-Django queryset filter – Q() | VS __in