> I'm no QueryParser expert, but I would probably start w/ the default
> query parser in Solr (LuceneQParser), and then progress a bit to the
> DisMax one.  I'd ask specific questions based on what you see there.
> If you get far enough along, you may consider asking for help on the
> java-user list as well.

Thanks - I think I've got it working now.  I ended up subclassing QueryParser 
and overriding newTermQuery() to create a BoostingTermQuery instead of a plain 
ol' TermQuery.  Seems to work.

> > Yup - I'm pretty sure I have that side figured out.  My input
> > contains terms marked up with a score (ie 'software?7')  I just
> > needed to create a TokenFilter that parses out the suffix and sets
> > the Payload on the token.
>
> Cool.  Patch?

Not sure how valuable it is - all I did was create a new subclass of 
TokenFilter.  Here's the code fwiw:

public class ScorePayloadFilter extends TokenFilter {

        protected ScorePayloadFilter(TokenStream input) {
                super(input);
        }

        public Token next(Token in) throws IOException {
                Token nextToken = input.next(in);

                if ( nextToken != null )
                {
                        char[] buf = nextToken.termBuffer();
                        int termLen = nextToken.termLength();
                        int posn = -1;

                        for ( int i=0; i < termLen; i++ )
                                if ( buf[i] == '?' )
                                        posn = i;

                        if ( posn > 0 )
                        {
                                int scorepos = posn + 1;
                                String score = new String(buf, scorepos, 
termLen - scorepos);
                                Integer scoreInt = new Integer(score);
                                Payload payload = new Payload();

                                byte[] payloadBytes = new byte[4];
                                
payload.setData(PayloadHelper.encodeInt(scoreInt, payloadBytes, 0));
                                nextToken.setPayload(payload);
                                nextToken.setTermLength(posn);
                        }
                }
                return nextToken;
        }
}

Thanks again for the help!

-Ken

Reply via email to