You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Justin Woody <ju...@comcast.net> on 2004/02/05 21:27:42 UTC

Query question

Hello all,

I am a relatively new user to Lucene. I have indexed several database
tables, but I am having problems returning the search results I would
like. Here is the example

I have unStored index on the description column

Description examples:
department a building 4
building 9 department 2
system builder room 89

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.

Thanks

Justin


Re: Search Refinement Approaches

Posted by Ramy Hardan <ja...@hardan.de>.
Sunday, February 8, 2004, 4:19:59 AM, Erik Hatcher wrote:

> On Feb 7, 2004, at 5:32 PM, Ramy Hardan wrote:
>> Is there an efficient way to search refinement preferably without
>> losing the Hits class?

> I'm not quite following your Filter questions, but QueryFilter seems to
> fit the bill for what you are trying to do.  Just keep around the 
> previous query, and filter on it for successive searches.

First, thanks for your answer. Basically QueryFilter provides what I
need. But isn't the search actually executed twice, once for
retrieving the Hits and once for creating the QueryFilter instance if
refinement is needed afterwards? This is what I try to prevent. I see
that for the same query and unmodified index I can reuse a queryFilter
but this is quite unlikely in my scenario. Additionaly QueryFilter
doesn't seem to be ready for multiple refinement steps (like searching
for printers - HP - Laser - more than 16 ppm).

I'll try to implement different approaches, profile them and come back
with some evidence rather than bothering you with my speculations.
Thanks

Ramy


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Re: Search Refinement Approaches

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Feb 7, 2004, at 5:32 PM, Ramy Hardan wrote:
> Is there an efficient way to search refinement preferably without
> losing the Hits class?

I'm not quite following your Filter questions, but QueryFilter seems to 
fit the bill for what you are trying to do.  Just keep around the 
previous query, and filter on it for successive searches.

> Last question about document numbers:
> When and how exactly do they change? The javadoc states they change
> upon addition and deletion. May I assume that a particular document
> number is stable as long as it is not changed (deleted and added)
> although other documents are added/deleted and optimize() is NOT
> called? If yes, is this about to change in the foreseeable future?

Document numbers change when a hole has been made by a delete and the 
index is optimized.  So, I think your assumption is fine, but 
personally I'm weary of relying on something potentially transient.  
Perhaps there is another way to accomplish what you are after?  A 
TermQuery is very fast, so maybe that could get you directly to a 
document of interest instead?

	Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Re: Search Refinement Approaches

Posted by Ramy Hardan <ja...@hardan.de>.
Hello Dror,

Sunday, February 8, 2004, 7:35:32 PM, you wrote:

> Hi Ramy,

> Maybe I'm misunderstand the question but wouldn't creating a 
> that ANDs the original query and the new one do what you want?

You are absolutely right. This approach would yield the desired
result. But what I'm concerned about is to find the most performant
way of achieving this. I'm afraid that queries become slower as they
get more complex (the refinement levels increase). The bottom line
probably is that I have to implement the different strategies and
compare their performance.

Thanks and best regards

Ramy

> On Sat, Feb 07, 2004 at 11:32:35PM +0100, Ramy Hardan wrote:
>> Hi,
>> 
>> Reviewing javadocs and previous posts, search refinement or 'search
>> within search' is best done with a Filter. To fill the Filter's BitSet
>> with the results of a search, a HitCollector is the obvious solution.
>> Unfortunately when using HitCollector I have to implement all the
>> functionality the Hits class usually provides myself.
>> 
>> Is there an efficient way to search refinement preferably without
>> losing the Hits class? I can think of the following approaches:
>> 
>> - Don't use Hits: collect all scores and document numbers with a
>>   HitCollector and sort them by score after the search. Retrieve the
>>   needed documents from IndexReader via document number.
>> - Use Hits: Briefly examining the source reveals this possiblilty:
>>   subclass BitSet and override the boolean get(int bitIndex) method to
>>   additionally set the bit at bitIndex in another BitSet. Use this
>>   subclass in a Filter and initialize it with all ones (in the first
>>   search). This way I can tell which documents are tested by the
>>   IndexSearcher against the Filter by examining the second BitSet and
>>   use it as a Filter for the refining search. Here's a scetch of this
>>   for clarification:
>> 
>>   public class FilterBitSet extends BitSet {
>>     private BitSet bitsForRefiningFilter;
>> 
>>     public boolean get( int bitIndex ) {
>>       boolean result = super.get( bitIndex );
>>       if (result) bitsForRefiningFilter.set( bitIndex );
>>       return result;
>>     }
>>   }
>> 
>>   Is this really possible? (might be more of a question for dev)




---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Re: Search Refinement Approaches

Posted by Dror Matalon <dr...@zapatec.com>.
Hi Ramy,

Maybe I'm misunderstand the question but wouldn't creating a 
that ANDs the original query and the new one do what you want?

so if the original query was
foo bar

and the refinment is 
blah

create a new query that does:

(foo bar) AND (bar)

Seems a lot easier but maybe I'm missing something.

Regards,

Dror

On Sat, Feb 07, 2004 at 11:32:35PM +0100, Ramy Hardan wrote:
> Hi,
> 
> Reviewing javadocs and previous posts, search refinement or 'search
> within search' is best done with a Filter. To fill the Filter's BitSet
> with the results of a search, a HitCollector is the obvious solution.
> Unfortunately when using HitCollector I have to implement all the
> functionality the Hits class usually provides myself.
> 
> Is there an efficient way to search refinement preferably without
> losing the Hits class? I can think of the following approaches:
> 
> - Don't use Hits: collect all scores and document numbers with a
>   HitCollector and sort them by score after the search. Retrieve the
>   needed documents from IndexReader via document number.
> - Use Hits: Briefly examining the source reveals this possiblilty:
>   subclass BitSet and override the boolean get(int bitIndex) method to
>   additionally set the bit at bitIndex in another BitSet. Use this
>   subclass in a Filter and initialize it with all ones (in the first
>   search). This way I can tell which documents are tested by the
>   IndexSearcher against the Filter by examining the second BitSet and
>   use it as a Filter for the refining search. Here's a scetch of this
>   for clarification:
> 
>   public class FilterBitSet extends BitSet {
>     private BitSet bitsForRefiningFilter;
> 
>     public boolean get( int bitIndex ) {
>       boolean result = super.get( bitIndex );
>       if (result) bitsForRefiningFilter.set( bitIndex );
>       return result;
>     }
>   }
> 
>   Is this really possible? (might be more of a question for dev)
> 
> Last question about document numbers:
> When and how exactly do they change? The javadoc states they change
> upon addition and deletion. May I assume that a particular document
> number is stable as long as it is not changed (deleted and added)
> although other documents are added/deleted and optimize() is NOT
> called? If yes, is this about to change in the foreseeable future?
> 
> Thanks in advance
> 
> Ramy
> 
>   
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
> 

-- 
Dror Matalon
Zapatec Inc 
1700 MLK Way
Berkeley, CA 94709
http://www.fastbuzz.com
http://www.zapatec.com

---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Search Refinement Approaches

Posted by Ramy Hardan <ja...@hardan.de>.
Hi,

Reviewing javadocs and previous posts, search refinement or 'search
within search' is best done with a Filter. To fill the Filter's BitSet
with the results of a search, a HitCollector is the obvious solution.
Unfortunately when using HitCollector I have to implement all the
functionality the Hits class usually provides myself.

Is there an efficient way to search refinement preferably without
losing the Hits class? I can think of the following approaches:

- Don't use Hits: collect all scores and document numbers with a
  HitCollector and sort them by score after the search. Retrieve the
  needed documents from IndexReader via document number.
- Use Hits: Briefly examining the source reveals this possiblilty:
  subclass BitSet and override the boolean get(int bitIndex) method to
  additionally set the bit at bitIndex in another BitSet. Use this
  subclass in a Filter and initialize it with all ones (in the first
  search). This way I can tell which documents are tested by the
  IndexSearcher against the Filter by examining the second BitSet and
  use it as a Filter for the refining search. Here's a scetch of this
  for clarification:

  public class FilterBitSet extends BitSet {
    private BitSet bitsForRefiningFilter;

    public boolean get( int bitIndex ) {
      boolean result = super.get( bitIndex );
      if (result) bitsForRefiningFilter.set( bitIndex );
      return result;
    }
  }

  Is this really possible? (might be more of a question for dev)

Last question about document numbers:
When and how exactly do they change? The javadoc states they change
upon addition and deletion. May I assume that a particular document
number is stable as long as it is not changed (deleted and added)
although other documents are added/deleted and optimize() is NOT
called? If yes, is this about to change in the foreseeable future?

Thanks in advance

Ramy

  



---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


RE: Query question

Posted by Justin Woody <ju...@comcast.net>.
Erik,

I think I found the problem. I thought queries were case sensitive, but
after running your AnalyzerDemo, it seems that it was indexing all of my
information in lower case. Anyway, when I did a toLowerCase() on my
search string, the expected results were returned. Does this sound
right?

Thanks
Justin

-----Original Message-----
From: Justin Woody [mailto:justin.woody@comcast.net] 
Sent: Friday, February 06, 2004 2:33 PM
To: 'Lucene Users List'
Subject: RE: Query question


Hi Erik,

The analysis class is parsing the terms as expected. However, no partial
terms will return results. I've tried the following:
build
build*
"build"
"build*"

All return 0 hits unless the entire word (in this case build) appears.
I've tried this with multiple keywords. Any other ideas?
Thanks,
Justin

Looking forward to your book, there's not enough info out there for
Lucene.

-----Original Message-----
From: Erik Hatcher [mailto:erik@ehatchersolutions.com] 
Sent: Friday, February 06, 2004 11:42 AM
To: Lucene Users List
Subject: Re: Query question


Everything you are doing looks ok to me.  Next step is to run some 
sample text through something like the AnalyzerDemo.analyze method 
shown here:

	<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:erik@ehatchersolutions.com]
> 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: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


RE: Query question

Posted by Justin Woody <ju...@comcast.net>.
Hi Erik,

The analysis class is parsing the terms as expected. However, no partial
terms will return results. I've tried the following:
build
build*
"build"
"build*"

All return 0 hits unless the entire word (in this case build) appears.
I've tried this with multiple keywords. Any other ideas?
Thanks,
Justin

Looking forward to your book, there's not enough info out there for
Lucene.

-----Original Message-----
From: Erik Hatcher [mailto:erik@ehatchersolutions.com] 
Sent: Friday, February 06, 2004 11:42 AM
To: Lucene Users List
Subject: Re: Query question


Everything you are doing looks ok to me.  Next step is to run some 
sample text through something like the AnalyzerDemo.analyze method 
shown here:

	<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:erik@ehatchersolutions.com]
> 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: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Re: Query question

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
Everything you are doing looks ok to me.  Next step is to run some 
sample text through something like the AnalyzerDemo.analyze method 
shown here:

	<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:erik@ehatchersolutions.com]
> 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: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


RE: Query question

Posted by Justin Woody <ju...@comcast.net>.
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:erik@ehatchersolutions.com] 
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: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Re: Query question

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
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: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org