<http://today.java.net/pub/a/today/2003/07/30/LuceneIntro.html>
Be sure to use real world data, although "builder building" would be a good first pass to ensure all is working well then. If you are really searching for "build*" using the code you've shown (without the quotes!) then it should work from my quick look at what you've done.
Erik
On Feb 6, 2004, at 9:27 AM, Justin Woody wrote:
Hi Erik,
Here is the IndexWriter with the Standard analyzer: Class variable: IndexWriter writer;
writer = IndexWriter(indexDirectory, new StandardAnalyzer(), true);
While looping over the ResultSet I call this method:
private void indexDoc(ResultSet rs) throws Exception { Document doc = new Document();
doc.add(Field.UnIndexed("value", rs.getString("value"))); doc.add(Field.UnIndexed("name", rs.getString("name")));
doc.add(Field.UnStored("content",rs.getString("indexed")));
writer.addDocument(doc); }
The "indexed" data is a concatenation of the Code and Desciptor(s) fields that they want to search by. They are concatenated with a space. Ex. Select col1 as value, col2 as name, col3 || ' ' || col2 || ' ' || col5 as indexed from tableName. Since there are many tables that are similar in structure I wrote the queries like this so I could multi thread the re indexing process on a frequent basis and use one generic class.
Here is my test search class:
public IndexSearchTest(String search, String index) throws Exception { String indexName = dirLucene + index +"/"; System.out.println("Index Name " + indexName);
IndexSearcher searcher = new IndexSearcher(IndexReader.open(indexName));
Query query = QueryParser.parse(search.toUpperCase(), "content",
new StandardAnalyzer());
Hits hits = searcher.search(query);
Document result;
System.out.println("Begin Search Results");
for (int i=0;i<hits.length();i++) {
result = hits.doc(i);
System.out.println("Key :" + result.get("value") + " Desc: "
+ result.get("name")) ;
}
System.out.println("Finished Search: " +hits.length());
}
Thanks in advance, Justin
-----Original Message----- From: Erik Hatcher [mailto:[EMAIL PROTECTED] Sent: Thursday, February 05, 2004 6:34 PM To: Lucene Users List Subject: Re: Query question
On Feb 5, 2004, at 3:27 PM, Justin Woody wrote:If I search the index for "building" it comes back fine (2 records) or
"builder" (1record), but if I search for "build*" I only receive one record, in my example, the second record. The client would like all 3 records to come back. Is there a way I can make that happen? I've been
trying different query types and syntax, but haven't been able to succeed.
We need more details to know what is going on. What analyzer are you using with indexing?
How are you building the query objects? QueryParser? Same Analyzer as with indexer?
(Succinct) code is the best :)
Erik
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
