Solr british and american spelling - solr

Search for 'globali*z*ation' only returns search results for 'globalization' but doesn't include any results for 'globali*s*ation' and vice versa.
I'm looking
into solr.HunspellStemFilterFactory filter (available in Solr 3.5).
<filter class="solr.HunspellStemFilterFactory" dictionary="en_GB.dic,en_US.dic" affix="en_GB.aff,en_US.aff" ignoreCase="true" />
Before upgrading from Solr 3.4 to 3.6.1 I was wondering if Hunspell filter is the way to go?
Thanks

If stemming doesn't solve this for you, you could always use a SynonymFilterFactory in order to normalize both spellings into one, I guess a dictionary containing US/UK spelling variations wouldn't be hard to come by.

Related

Synonyms are not working ibm watson retrieve and rank

This is my synonyms.txt
file system => filesystem
file set => fileset
version , release
latest, new
content, information
I have changed the synonyms.txt but synonyms are not working also help me to how to give space separated synonyms.
eg.
foo bar => foobar
The field type "watson_text_en" we use in retrieve and rank doesn't have synonyms filter by default. You would need to update your schema.xml by adding that filter to make it available. Here is an instruction of where and what to add: In your schema.xml, in section, add <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/> into the tag list.
Depending on your requirement, you can add it to both/either of and , which tell solr whether to apply it in indexing and/or query time. Adding it to "index" would require reindexing to make the change effective, while adding into "query" does not. Also, list will run in the order you put it, so you can choose where to put this filter to let it run before/after certain filters. For example, if you put it before solr.LowerCaseFilterFactory, it's better to toggle on ignoreCase="true", because it will run before everything is transformed into lower case
Just to note regarding adding the filter into 'Query' - according to the Solr docs, http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters#solr.SynonymFilterFactory this is a Very Bad Thing to Do.

Show all occurrences of query while highlighting in solr 1.4

I have a solr setup(1.4) having a text field with ebook data. The params while hitting solr are -
"hl.fragsize":"0",
"indent":"1",
"hl.simple.pre":"{{{",
"hl.fl":"body_eng",
"hl.maxAnalyzedChars":"-1",
"wt":"json",
"hl":"true",
"rows":"1",
"fl":"ia,body_length,page_count",
"q":"ia:talesofpunjabtol00stee AND PUNJAB",
"q.op":"AND",
"f.body_eng.hl.snippets":"428",
"hl.simple.post":"}}}",
"hl.usePhraseHighlighter":"true"}},
However, the results show only 20 highlighted occurrences of word PUNJAB.
I tried f.body_eng.hl.snippets":"428" but this even isnt working.
body_eng is a big text field. The highlighting works only till some length. I have tried other words as well. In all the examples, highlighting works till around 54K letter counts.
What could be the reason?
First of all: 1.4 is a very old version of Solr. I'm not sure if per field values were supported at that time (Highlighting itself was introduced with Solr 1.3). The default highlighter was changed in 3.1.
You should however be able to highlight all occurences in a field by supplying a large value for hl.maxAnalyzedChars (not sure if -1 will do what you want). Another option to try should be to have a large hl.maxAnalyzedChars value and a large hl.fragsize value (use the same value for both fields and not 0).
If you're still unable to get it to work, test it on a more recent version of Solr to see if it's an issue that has already been fixed.
So, after lot of asking around, Its working now.
The query params is correct. The schema was causing problems. Changes done were -
<filter class="solr.SnowballPorterFilterFactory" language="English" />
was replaced with
with <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />

Solr: Localities & solr.ICUCollationField usage?

I'm learning Solr and have become confused trying to figure out ICUCollation, what it does, what it is for and how to use it. From here. I haven't found any good explanation of this online. The doc appear to be saying that I need to use this ICUCollation and implies that it does magical things for me, but does not seem to explain exactly why or exactly what, and how it integrates with anything else.
Say I have a text field in French and I want stopwords removed, accents, punctuation and case ignored and stemming... how does ICUCollation come into this? Do I set solr.ICUCollationField and locale='fr' and it will do everything else automatically? Or do I set solr.ICUCollationField and then tokenizer and filters on this in addition? Or do I not use solr.ICUCollationField at all because that's for something completely different? And if so, then what?
Collation is the organisation of written information into an order - ICUCollactionField (the API documentation also provides a good description) is meant to enable you to provide locale aware sorting, as the sort order is defined by cultural norms and specific language properties. This is useful to allow different sorting based on those rules, such as the difference between Norwegian and Swedish, where a Swede would order Å before Æ/Ä and Ø/Ö, while a Norwegian would order it Æ/Ä, Ø/Ö and then Å.
Since you usually don't want to sort by a tokenized field (exception: KeywordTokenizer) or a multivalued field, these fields are usually not processed any more than allowing for the sorting / collation to be performed.
There is a case to be made for collation filters for searching as well, as search in practice is just comparison. This means that if you're aiming to search for two words that would be identical when compared in the locale provided, it would be a hit. The tokens indexed will not make any sense when inspected, but as long as the values are reduced to the same token both when indexing and searching, it would work. There's an example of this on the wiki under UnicodeCollation.
Collation does not affect stopwords (StopFilterFactory), accents (ICUFoldingFilterFactory), punctuation, case (depending on locale - if the locale for sorting is case aware, then it does not) (LowercaseFilterFactory or ICUNormalizer2FilterFactory) or stemming (SnowballPorterFilterFactory). Have a look at the suggested filters for that. Most filters or tokenizers in Solr does very specific tasks, and try to avoid doing "everything and the kitchen sink" in one single filter.
You normally have two or more fields for one text input if you want to do different things like:
search: text analysis
sort: language sensitive / case insensitive sorting
facet: string
For search use something like:
<fieldType name="textFR" class="solr.TextField" positionIncrementGap="100">
<analyzer>
<tokenizer class="solr.ICUTokenizerFactory"/>
<filter class="solr.ICUFoldingFilterFactory"/>
<filter class="solr.ElisionFilterFactory"/>
<filter class="solr.KeywordRepeatFilterFactory"/>
<filter class="solr.FrenchLightStemFilterFactory"/>
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
</analyzer>
</fieldType>
For sorting use:
<fieldType name="textSortFR" class="solr.ICUCollationField"
locale="fr"
strength="primary" />
or simply:
<fieldType name="textSort" class="solr.ICUCollationField"
locale=""
strength="primary" />
(If you have to support many languages. Should work fine enough in most cases.)
Do make use of the Analysis UI in the SOLR Admin: open the analysis view for your index, select the field type (e.g. your sort field), add a representative input value in the left text area and a test value in the right field (in case of sorting, this right side value is not as interesting as the sort field is not used for matching).
The output will show you whether:
accents are removed
elisions are removed
lower casing is applied
etc.
For example, if you see that elisions (l'atelier) are not remove (atelier) but you would like to discard it for sorting you would have to add the elision filter (see example for search field type above).
https://cwiki.apache.org/confluence/display/solr/Language+Analysis

SOLR Snowball Porter for Arabic

is there a Snowball Porter Filter or any similar filter for Arabic?
<filter class="solr.SnowballPorterFilterFactory" language="English" />
I need it to normalize plural words into singular words for the Arabic language
Solr does provide language support for quite a wide range of languages.
Check for the Arabic ones # link
Documentation :-
Provides character normalization and stemming
If you have english and arabic text you can check Solr Language Detection which will help you keep the fields separate and search accordingly.

How to do partial beginning matches in Solr?

I'm trying to search for partial beginning matches on a big list of lastnames. So Wein* should find Weinberg, Weinkamm etc.
I could do this by creating a special field, and adding
<filter class="solr.EdgeNGramFilterFactory" minGramSize="1" maxGramSize="50" preserveOriginal="1"/>
to its type specification in schema.xml. When I add the line above only to the indexing analyzer and leave it empty for the query analyzer, I can then search by just search special_field:Wein and get the expected results.
Now I see that solr also has a *-syntax. What's the connection between EdgeNGramFilterFactory and the *-syntax?
Am I doing things correctly or is there a better, more regular way?
Thanks!
Or just do a simple wild card match:
name:Pe*
I don't recommend the Wein* query. That is implemented internally as PrefixQuery, which rewrites the original query to include all terms that have prefix equals "Wein". Depending on how large is your index (I mean how many terms), this query rewriting can be a bottleneck.
The EdgeNGramFilter at index time is a better approach. This solution will use more space, but queries will be processed much faster.
Note: I also asked this question in the Lucene forum where I got a good answer:
http://lucene.472066.n3.nabble.com/How-to-do-partial-beginning-matches-td781147.html

Resources