I&#39;ve written a tokenizer/analyzer that parses a file extracting tokens and operate this analyzer/tokenizer on ASCII data consisting of XML files (the tokenizer skips over XML elements but maintains relative positioning). I&#39;ve written many units tests to check the produced token stream and was confident that the tokenizer was working properly. Then I noticed two problems:<br>
<ol><li>StopFilter (using English stop words) does not properly filter the token stream output from my tokenizer. If I explicitly pass an array of stop words to the stop filter it still doesn&#39;t work. If I simply switch my tokenizer to a StandardTokenizer the stop words are appropriately filtered (of course the XML tags are treated differently). <br>
</li><li>When I try a simple search no results come up. I can see that my tokenizer is adding files to the index but a simple search (using Ferret::Index::Index.search_each) produces no results. <br></li></ol>I&#39;m now trying to track down the above problem which seems to have led me to another (though possibly related) problem for which I am seeking an answer. Below is the token_stream() method of my analyzer (XMLAnalyzer). Note that I&#39;ve commented out my custom tokenizer (XMLTokenizer) so that the StandardTokenizer is being used within my custom analyzer. <br>
&nbsp;&nbsp;&nbsp;&nbsp; def token_stream(field, str)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # ts = XMLTokenizer.new(str)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ts = StandardTokenizer.new(str)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # test_token_stream(ts)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ts<br>&nbsp;&nbsp;&nbsp;&nbsp; end<br>In the above I&#39;ve commented out the test_token_stream() method taken from Balmain&#39;s Ferret book (O&#39;Reilly, pg 68) that simply prints out the tokens contained within a stream; i.e.,: <br>
&nbsp;&nbsp;&nbsp;&nbsp; def test_token_stream(token_stream)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; puts &quot;\033[32mStart | End | PosInc | Text\033[m&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while tkn = token_stream.next<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; puts &quot;%5d |%4d |%5d&nbsp;&nbsp; | %s&quot; % [tkn.start, tkn.end, tkn.pos_inc, tkn.text]<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end<br>&nbsp;&nbsp;&nbsp; end<br><br>If I keep test_token_stream() commented out then the indexing and search work fine (using StandardTokenizer). However, if I do not comment out test_token_stream() then creating the index appears to work fine but a search produces no results. I haven&#39;t been able to track this down but thought it might be related to the problems I was having with XMLTokenizer. Note that I create my index with the Ferret::Index::Index<br>
<br>&nbsp; index = Index::Index.new(:analyzer =&gt; XMLAnalyzer.new(),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :path =&gt; options.indexLocation,<br>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :create_if_missing =&gt; true)<br>
<br>and I perform searches using Ferret::Search::Searcher<br><br>Any thoughts would be appreciated. <br><br>Regards,<br>John<br>aka sd.codewarrior<br><br><br><br>