spinergywmy schrieb:
> Hi Erick,
> 
>    I did take a look at the link that u provided me, and I have try myself
> but I have no return reesult.
> 
>    My search string is "third party license readme"
> 
hhm with a quick look I would suggest that you have to split the string
into individual terms, and then make a spannearquery  for these Terms:

        String[] que_ary = system_query.split("\\s");
        //=> Array with third,party,licens,readme
        SpanQuery[] spanq_ar = new SpanQuery[que_ary.length];
        
        for (int i=0; i < que_ary.length; i++) {
                spanq_ar[i] = new SpanTermQuery( new Term("TI", que_ary[i]) );
        }
        // now we have an array of spantermquerys

        // each term of the sentence should be in exact order => spannearquery
        //  I am not sure if you'll better do a slop of "0"
        SpanFirstQuery sfq = new SpanFirstQuery(
                                                        new 
SpanNearQuery(spanq_ar,1,true), spanq_ar.length);


hth,
martin

>    Below r the codes that I wrote, please point me out where I have done
> wrong.
> 
>       readerA = IndexReader.open(DsConstant.indexDir);
>                       readerB = IndexReader.open(DsConstant.idxCompDir);
>                       
>                       //building the searchables
>               Searcher[] searchers = new Searcher[2];
>               
>               // VITAL STEP:adding the searcher for the empty index first, 
> before
> the searcher for the populated index
>               searchers[0] = new IndexSearcher(readerA);
>               searchers[1] = new IndexSearcher(readerB);
>               
>                       Analyzer analyzer = new StandardAnalyzer();
>                       QueryParser parser = new 
> QueryParser(DsConstant.idxFileContent,
> analyzer);
> 
>       SpanTermQuery stq = new SpanTermQuery(new Term(field,
> buff.toString())); //field = search base on what I have index
>                               SpanFirstQuery sfq = new SpanFirstQuery(stq, 
> searchString1.length);
> //searchString1 = "third party license readme"
>                               
>                               sfq = (SpanFirstQuery) sfq.rewrite(readerA);
>                               sfq = (SpanFirstQuery) sfq.rewrite(readerB);
>                               
>                               //creating the multiSearcher
>                       Searcher mSearcher = 
> getMultiSearcherInstance(searchers);
>                               
>                               searchHits = mSearcher.search(sfq);
> 
>    The sysout as below:
> 
>       span first query is ::: spanFirst(TestC:TestC:Third Party License
> Readme, 32)



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to