Why lucene fail to return results while searching for mathcing phrase?
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   blazzing_wolf
Posted On:   Monday, April 27, 2009 11:54 PM

Why lucene fail to return results while searching for mathcing phrase? When i print out the query, it will be like this: (url:"terror india"^2.0 anchor:"terror india"^0.0 content:"terror india" title:"terror india"^1.5 host:"terror india"^2.0 site:"terror india"^10.0) I dont understand at all, only phrase query got problem, even my sloop has no problem at all. I have exact match in my content, so it should return at least 1 document This is a simplified version of my code, but it still doesnt return any results public static void main(String[] args) throws Exception { String indexDir ="C   More>>

Why lucene fail to return results while searching for mathcing phrase?


When i print out the query, it will be like this:
(url:"terror india"^2.0 anchor:"terror india"^0.0 content:"terror india" title:"terror india"^1.5 host:"terror india"^2.0 site:"terror india"^10.0)




I dont understand at all, only phrase query got problem, even my sloop has no problem at all. I have exact match in my content, so it should return at least 1 document




This is a simplified version of my code, but it still doesnt return any results

public static void main(String[] args) throws Exception {

String indexDir ="C:/Project/search/crawl/segments/20090420152908/index";
String []phrase = {"terror", "india"};


IndexSearcher searcher = new IndexSearcher(indexDir);

PhraseQuery query = new PhraseQuery();

query.setSlop(0);

for (int i=0; i < phrase.length; i++) {

query.add(new Term("content",
phrase[i]));

}

System.out.println("Query: " + query);

Hits hits = searcher.search(query);



for(int i=0; i

System.out.println("---1---");

Document document = hits.doc(i);

System.out.println(document.get("info"));

System.out.println(hits.score(i));

}



}

   <<Less
About | Sitemap | Contact