Oh you are constructing the string 'fly +body:away' in your StemFilter?
Just to make sure, does this q=+body:(fly away) return your document?
And analysis.jsp (at query time) displays 'fly +body:away' from the string 
'flyaway'?

I don't know why are you doing this but your stemfilter should return only 
terms, not field names attached to it.

Maybe you can find this useful so that you can do what you want without writing 
custom code.
 
http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters#solr.SynonymFilterFactory



         

--- On Tue, 10/19/10, Jerad <ag...@naver.com> wrote:

> From: Jerad <ag...@naver.com>
> Subject: Re: How can i get collect stemmed query?
> To: solr-user@lucene.apache.org
> Date: Tuesday, October 19, 2010, 5:10 AM
> 
> Thanks for your reply :)
> 
> 1. I tested that "q=*:*&fl=body" , 1 doc returned as
> result as I expected.
> 
> 2. I'm edit my scheme.xml as you instructed. 
> 
>     <analyzer type="query"
> class="com.testsolr.ir.customAnalyzer.MyCustomQueryAnalyzer">
> 
>         //No filter description.
>     </analyzer> 
> 
>     but no result returned.
> 
> 3. I wonder that...
> 
>     Tipically Tokenizer and filter flow was
> 
>     1) Input stream provide text stream to
> tokenizer or filter.
>     2) tokenizer or filter get a token, and
> processed token and offset
> attribute info has returned.
>     3) offset attributes has the infomation of
> token's.
>     
>         This is a part of tipical
> filter src that I thought.
>        
> ------------------------------------------------------------------------------------
>         public class CustomStemFilter
> extends TokenFilter {
> 
>             private
> MyCustomStemer stemmer;
>             private
> TermAttribute termAttr;
>             private
> OffsetAttribute offsetAttr;
>             private
> TypeAttribute typeAttr;
>             private
> Hashtable<String,String> reserved = new
> Hashtable<String,String>();
>             
>             public
> CustomStemFilter( TokenStream tokenStream, boolean isQuery,
> MyCustomStemer stemmer ){
>              
>   super( tokenStream );
>                 
>              
>   this.stemmer = stemmer;
>              
>   termAttr   = (TermAttribute)
> addAttribute(TermAttribute.class);   
>              
>   offsetAttr = (OffsetAttribute)
> addAttribute(OffsetAttribute.class);   
>                
> typeAttr   = (TypeAttribute)
> addAttribute(TypeAttribute.class);   
>                
> addAttribute(PositionIncrementAttribute.class);
>             
>                
> //Some of my custom logic here.
>                
> //do something.
>             }
>             
>             private
> MyCustomStemmer stemmer = new MyCustomStemmer();
>             
>             public boolean
> incrementToken() throws IOException {
>                
> clearAttributes();
>             
>                 if
> (!input.incrementToken())
>                
>     return false;
> 
>                
> StringBuffer queryBuffer = new StringBuffer();
>                 
>                
> //stemming logic here.
>                
> //generated query string has append to queryBuffer.
>                 
>              
>   termAttr.setTermBuffer(queryBuffer.toString(), 0,
> queryBuffer.length());
>              
>   offsetAttr.setOffset(0, queryBuffer.length());
>             
>       offSet += queryBuffer.length();
>             
>       typeAttr.setType("word");
>             
>       
>             
>       return true;
>             }
>         }
>        
> ------------------------------------------------------------------------------------
> 
>         ※ MyCustomStemmer analyze
> input string "flyaway" to query string :
> fly +body:away
>            and return
> it.
> 
>         At index time, contents to be
> searched is normally analyzed and
> indexed as below.
>         
>         a) Contents to be indexed : fly
> away
>         b) Token "fly" and length of
> "fly" = 3(Has been setup by offset
> attribute method) 
>            has returned
> by filter or analyzer.
>         c) Next token "away" and length
> of "away" = 4 has returned.
>         
>         I think it's a general index
> flow.
> 
>         But, I customized
> MyCustomFilter that filter generate query string,
> not a token.
>         In the process, offset value
> has changed : query's length, not a
> single token's length.
>         
>         I wonder that value to be set
> up by offsetAttr.setOffset() method 
>         has influence on search result
> on using solr? 
>         (I tested this on main page's
> query input box at
> http://localhost:8983/solr/admin/ )
> 

> 
> -- 
> View this message in context: 
> http://lucene.472066.n3.nabble.com/How-can-i-get-collect-search-result-from-custom-filtered-query-tp1723055p1729717.html
> Sent from the Solr - User mailing list archive at
> Nabble.com.
> 



Reply via email to