lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mharw...@apache.org
Subject svn commit: r379586 - in /lucene/java/trunk/contrib/highlighter/src: java/org/apache/lucene/search/highlight/QueryTermExtractor.java test/org/apache/lucene/search/highlight/HighlighterTest.java
Date Tue, 21 Feb 2006 21:05:22 GMT
Author: mharwood
Date: Tue Feb 21 13:05:18 2006
New Revision: 379586

URL: http://svn.apache.org/viewcvs?rev=379586&view=rev
Log:
Removed use of deprecated APIs ready for 2.0 Lucene release

Modified:
    lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/QueryTermExtractor.java
    lucene/java/trunk/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java

Modified: lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/QueryTermExtractor.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/QueryTermExtractor.java?rev=379586&r1=379585&r2=379586&view=diff
==============================================================================
--- lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/QueryTermExtractor.java
(original)
+++ lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/QueryTermExtractor.java
Tue Feb 21 13:05:18 2006
@@ -134,8 +134,12 @@
 
 		for (i = 0; i < queryClauses.length; i++)
 		{
-			if (prohibited || !queryClauses[i].prohibited)
-				getTerms(queryClauses[i].query, terms, prohibited, fieldName);
+			//Pre Lucene 2.0 code
+//			if (prohibited || !queryClauses[i].prohibited)
+//				getTerms(queryClauses[i].query, terms, prohibited, fieldName);
+			// Lucene 2.0 ready code
+			if (prohibited || queryClauses[i].getOccur()!=BooleanClause.Occur.MUST_NOT)
+				getTerms(queryClauses[i].getQuery(), terms, prohibited, fieldName);
 		}
 	}
 

Modified: lucene/java/trunk/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java?rev=379586&r1=379585&r2=379586&view=diff
==============================================================================
--- lucene/java/trunk/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
(original)
+++ lucene/java/trunk/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
Tue Feb 21 13:05:18 2006
@@ -222,7 +222,8 @@
 		String srchkey = "football";
 
 		String s = "football-soccer in the euro 2004 footie competition";
-		Query query = QueryParser.parse(srchkey, "bookid", analyzer);
+		QueryParser parser=new QueryParser("bookid",analyzer);
+		Query query = parser.parse(srchkey);
 
 		Highlighter highlighter = new Highlighter(new QueryScorer(query));
 		TokenStream tokenStream =
@@ -289,7 +290,7 @@
 			new Highlighter(this,new QueryScorer(query));
 		highlighter.setMaxDocBytesToAnalyze(30);
 		TokenStream tokenStream=analyzer.tokenStream(FIELD_NAME,new StringReader(texts[0]));
-		String result = highlighter.getBestFragment(tokenStream,texts[0]);
+		highlighter.getBestFragment(tokenStream,texts[0]);
 		assertTrue("Setting MaxDocBytesToAnalyze should have prevented " +
 			"us from finding matches for this record: " + numHighlights +
 			 " found", numHighlights == 0);
@@ -302,7 +303,9 @@
 		//test to show how rewritten query can still be used
 		searcher = new IndexSearcher(ramDir);
 		Analyzer analyzer=new StandardAnalyzer();
-		Query query = QueryParser.parse("JF? or Kenned*", FIELD_NAME, analyzer);
+
+		QueryParser parser=new QueryParser(FIELD_NAME,analyzer);	
+		Query query = parser.parse("JF? or Kenned*");
 		System.out.println("Searching with primitive query");
 		//forget to set this and...
 		//query=query.rewrite(reader);
@@ -406,7 +409,7 @@
 		RAMDirectory ramDir1 = new RAMDirectory();
 		IndexWriter writer1 = new IndexWriter(ramDir1, new StandardAnalyzer(), true);
 		Document d = new Document();
-		Field f = new Field(FIELD_NAME, "multiOne", true, true, true);
+		Field f = new Field(FIELD_NAME, "multiOne", Field.Store.YES, Field.Index.TOKENIZED);
 		d.add(f);
 		writer1.addDocument(d);
 		writer1.optimize();
@@ -417,7 +420,7 @@
 		RAMDirectory ramDir2 = new RAMDirectory();
 		IndexWriter writer2 = new IndexWriter(ramDir2, new StandardAnalyzer(), true);
 		d = new Document();
-		f = new Field(FIELD_NAME, "multiTwo", true, true, true);
+		f = new Field(FIELD_NAME, "multiTwo", Field.Store.YES, Field.Index.TOKENIZED);
 		d.add(f);
 		writer2.addDocument(d);
 		writer2.optimize();
@@ -430,7 +433,8 @@
 		searchers[0] = new IndexSearcher(ramDir1);
 		searchers[1] = new IndexSearcher(ramDir2);
 		MultiSearcher multiSearcher=new MultiSearcher(searchers);
-		query = QueryParser.parse("multi*", FIELD_NAME, new StandardAnalyzer());
+		QueryParser parser=new QueryParser(FIELD_NAME, new StandardAnalyzer());
+		query = parser.parse("multi*");
 		System.out.println("Searching for: " + query.toString(FIELD_NAME));
 		//at this point the multisearcher calls combine(query[])
 		hits = multiSearcher.search(query);
@@ -536,7 +540,8 @@
 	public void doSearching(String queryString) throws Exception
 	{
 		searcher = new IndexSearcher(ramDir);
-		query = QueryParser.parse(queryString, FIELD_NAME, new StandardAnalyzer());
+		QueryParser parser=new QueryParser(FIELD_NAME, new StandardAnalyzer());
+		query = parser.parse(queryString);
 		//for any multi-term queries to work (prefix, wildcard, range,fuzzy etc) you must use a
rewritten query!
 		query=query.rewrite(reader);
 		System.out.println("Searching for: " + query.toString(FIELD_NAME));
@@ -585,7 +590,7 @@
 	private void addDoc(IndexWriter writer, String text) throws IOException
 	{
 		Document d = new Document();
-		Field f = new Field(FIELD_NAME, text, true, true, true);
+		Field f = new Field(FIELD_NAME, text,Field.Store.YES, Field.Index.TOKENIZED);
 		d.add(f);
 		writer.addDocument(d);
 



Mime
View raw message