lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Spencer Tickner" <>
Subject Extracting terms from a query splitting a phrase.
Date Tue, 05 Feb 2008 20:03:19 GMT
Hi List,

Thanks in advance for the help. I'm trying to extract terms from a
query. From the reading I've done a phrase such as "General Act" is
considered a term. .
However when I'm doing testing to get the extractTerms of my query it
splits this into General and Act. I'm wondering if I'm missing or not
understanding something.

My test Java code is:

        private String FIELD_NAME = "rr_root";
        private Query query;
        private Hits hits = null;

	public void testSearch() throws Exception
		doSearching("\"General Act\"");
		HashSet terms = new HashSet();
		int i = 0;
		for (Iterator iter = terms.iterator(); iter.hasNext();)
			Term term = (Term);
			System.out.println(i + " " + "term-" + term.text() + " field-" +

	public void doSearching(String queryString) throws Exception
		QueryParser parser=new QueryParser(FIELD_NAME, new WhitespaceAnalyzer());
		query = parser.parse(queryString);
	public void doSearching(Query unReWrittenQuery) throws Exception
		searcher = aspect.getSearcher(); // searcher comming from a cahed class
		query=unReWrittenQuery.rewrite(aspect.getReader()); // reader
comming from a cached class
		System.out.println("Searching for: " + query.toString(FIELD_NAME));
		hits =;

The current output is:

Searching for: "General Act"
1 term-General field-rr_root
2 term-Act field-rr_root

The output I expect is:

Searching for: "General Act"
1 term-General Act field-rr_root

Thanks for any help.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message