From fc0d666c814d6ad73b2c56f44bab2253c42761d7 Mon Sep 17 00:00:00 2001 From: Yonik Seeley Date: Thu, 6 Apr 2006 17:12:44 +0000 Subject: [PATCH] added getTermArrays() and extractTerms() to MultiPhraseQuery: LUCENE-514 git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@392016 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 4 ++++ .../lucene/search/MultiPhraseQuery.java | 23 ++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 32de72fe294..4c45a31b11f 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -41,6 +41,10 @@ Bug fixes 8. LUCENE-541: Add missing extractTerms() to DisjunctionMaxQuery (Stefan Will via Yonik Seeley) + 9. LUCENE-514: Added getTermArrays() and extractTerms() to + MultiPhraseQuery (Eric Jain & Yonik Seeley) + + 1.9.1 Bug fixes diff --git a/src/java/org/apache/lucene/search/MultiPhraseQuery.java b/src/java/org/apache/lucene/search/MultiPhraseQuery.java index 17ce727dff7..aa739d45064 100644 --- a/src/java/org/apache/lucene/search/MultiPhraseQuery.java +++ b/src/java/org/apache/lucene/search/MultiPhraseQuery.java @@ -17,9 +17,7 @@ package org.apache.lucene.search; */ import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.Vector; +import java.util.*; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.MultipleTermPositions; @@ -97,6 +95,14 @@ public class MultiPhraseQuery extends Query { positions.addElement(new Integer(position)); } + /** + * Returns a List of the terms in the multiphrase. + * Do not modify the List or it's contents. + */ + public List getTermArrays() { + return Collections.unmodifiableList(termArrays); + } + /** * Returns the relative positions of terms in this phrase. */ @@ -107,6 +113,17 @@ public class MultiPhraseQuery extends Query { return result; } + // inherit javadoc + public void extractTerms(Set terms) { + for (Iterator iter = termArrays.iterator(); iter.hasNext();) { + Term[] arr = (Term[])iter.next(); + for (int i=0; i