<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>wildcard &#8211; Solr.pl</title>
	<atom:link href="https://solr.pl/en/tag/wildcard/feed/" rel="self" type="application/rss+xml" />
	<link>https://solr.pl/en/</link>
	<description>All things to be found - Blog related to Apache Solr &#38; Lucene projects - https://solr.apache.org</description>
	<lastBuildDate>Tue, 10 Nov 2020 22:41:45 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>
	<item>
		<title>Wildcard queries and how Solr handles them</title>
		<link>https://solr.pl/en/2010/12/20/wildcard-queries-and-how-solr-handles-them/</link>
					<comments>https://solr.pl/en/2010/12/20/wildcard-queries-and-how-solr-handles-them/#respond</comments>
		
		<dc:creator><![CDATA[Rafał Kuć]]></dc:creator>
		<pubDate>Mon, 20 Dec 2010 22:41:09 +0000</pubDate>
				<category><![CDATA[Solr]]></category>
		<category><![CDATA[wildcard]]></category>
		<guid isPermaLink="false">http://sematext.solr.pl/?p=162</guid>

					<description><![CDATA[One of our readers reported a very interesting problem, which can be summarized to the following question &#8211; &#8220;Why doesn&#8217;t ReversedWildcardFilterFactory doesn&#8217;t work with Polish letters ?&#8221;. This entry will attempt to answer this question. Type and field definition Our]]></description>
										<content:encoded><![CDATA[<p>One of our readers reported a very interesting problem, which can be summarized to the following question &#8211; &#8220;Why doesn&#8217;t ReversedWildcardFilterFactory doesn&#8217;t work with Polish letters ?&#8221;. This entry will attempt to answer this question.</p>
<p><span id="more-162"></span></p>
<h2>Type and field definition</h2>
<p>Our reader has the following type of data defined in the schema.xml file:
</p>
<pre class="brush:xml">&lt;fieldType name="c_string" class="solr.TextField"&gt;
 &lt;analyzer type="index"&gt;
  &lt;tokenizer class="solr.KeywordTokenizerFactory"/&gt;
  &lt;filter class="solr.ASCIIFoldingFilterFactory"/&gt;
  &lt;filter class="solr.LowerCaseFilterFactory" /&gt;
  &lt;filter class="solr.ReversedWildcardFilterFactory" /&gt;
 &lt;/analyzer&gt;
 &lt;analyzer type="query"&gt;
  &lt;tokenizer class="solr.KeywordTokenizerFactory"/&gt;
  &lt;filter class="solr.ASCIIFoldingFilterFactory"/&gt;
  &lt;filter class="solr.LowerCaseFilterFactory" /&gt;
  &lt;filter class="solr.ReversedWildcardFilterFactory" /&gt;
 &lt;/analyzer&gt;
&lt;/fieldType&gt;
</pre>
<p>One of the fields in the schema.xml file looks like this:
</p>
<pre class="brush:xml">&lt;field name="word" type="c_string" indexed="true" stored="true" /&gt;
</pre>
<h2>Data</h2>
<p>For the purpose of this post I used the following data:
</p>
<pre class="brush:xml">&lt;add&gt;
 &lt;doc&gt;
  &lt;field name="id"&gt;1&lt;/field&gt;
  &lt;field name="word"&gt;Zażółć gęślą jaźń&lt;/field&gt;
 &lt;/doc&gt;
&lt;/add&gt;
</pre>
<h2>Problem definition</h2>
<p>The problem has been defined as follows: &#8220;<em>I have the Polish characters in the field named word. When I make a wildcard request with the Polish character, such as &#8220;word:*ą*&#8221; Solr doesn&#8217;t find any documents</em>&#8220;.</p>
<h2>What should we remember when using ReversedWildcardFilterFactory</h2>
<p>When using <em>ReversedWildcardFilterFactory </em>be sure to define this filter only for the index analyzer, and not to define it for query analyzer. Thus, a revised <em>c_string</em> definition should look like this:
</p>
<pre class="brush:xml">&lt;fieldType name="c_string" class="solr.TextField"&gt;
 &lt;analyzer type="index"&gt;
  &lt;tokenizer class="solr.KeywordTokenizerFactory"/&gt;
  &lt;filter class="solr.ASCIIFoldingFilterFactory"/&gt;
  &lt;filter class="solr.LowerCaseFilterFactory" /&gt;
  &lt;filter class="solr.ReversedWildcardFilterFactory" /&gt;
 &lt;/analyzer&gt;
 &lt;analyzer type="query"&gt;
  &lt;tokenizer class="solr.KeywordTokenizerFactory"/&gt;
  &lt;filter class="solr.ASCIIFoldingFilterFactory"/&gt;
  &lt;filter class="solr.LowerCaseFilterFactory" /&gt;
 &lt;/analyzer&gt;
&lt;/fieldType&gt;</pre>
<h2>Is it working now ?</h2>
<p>When we send the follwing query to Solr:
</p>
<pre class="brush:xml">http://localhost:8983/solr/select?q=word:*ś*</pre>
<p>It still does not return any results. Why ?</p>
<h2>Solr and wildcard handling</h2>
<p>The answer to the question posted above is simple enough &#8211; Solr does not analyze queries in which there are wildcards. Yes, this means that the filter <em>ASCIIFoldingFilterFactory</em>, during indexing, turns Polish characters onto their counterparts from the ASCII table characters, but when making queries this is not happening, despite the fact that the filters are defined correctly. And that is why we do not get any search results. However, in this was the case, we should get the query results after sending the following query:
</p>
<pre class="brush:xml">http://localhost:8983/solr/select?q=word:*s*</pre>
<p>And this is exactly the case, the above returns the search results we expected.</p>
<h2>Possible solutions</h2>
<p>If someone asked me what would I suggested to solve the problem, I would reply that at this time I would remove the Polish characters from the queries which have wildcards. Since version 1.5, Solr, <em>ReversedWildcardFilterFactory </em>will correctly handle characters outside the basic ASCII table, so there will be no need to use <em>ASCIIFoldingFilterFactory</em>, and hence, the problem will not exist.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://solr.pl/en/2010/12/20/wildcard-queries-and-how-solr-handles-them/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
