Lucene DB indexing and searching Question (1.9.1)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Lucene DB indexing and searching Question (1.9.1)

Audrius Peseckis
Hello,

What I'm trying to do is to index database with lucene. Each row returned by SQL query is represented as document, and document contains fields (values of columns). I'm adding those fields to document by doing the following:
Field fld = new Field("COLUMN_NAME", column.value());

Now when I'm trying to search the index, I only get the values of the column text (default field name).
Searcher searcher = new IndexSearcher(DIR);
QueryParser qp = new QueryParser("text", new StandardAnalyzer());
Query query = qp.parse("a*");

How to query a search engine, if I want to get results from all indexed fields, not only default provided?

Thanks in advance,
Audrius
Reply | Threaded
Open this post in threaded view
|

Re: Lucene DB indexing and searching Question (1.9.1)

chrislusf
You need to use MultiFieldQueryParser

http://lucene.apache.org/java/docs/api/org/apache/lucene/queryParser/MultiFieldQueryParser.html

Sincerely,
Chris Lu
---------
Full-text search on Any Databases/Applications
http://www.dbsight.net


On 4/27/06, Audrius Peseckis <[hidden email]> wrote:

> Hello,
>
> What I'm trying to do is to index database with lucene. Each row returned by SQL query is represented as document, and document contains fields (values of columns). I'm adding those fields to document by doing the following:
> Field fld = new Field("COLUMN_NAME", column.value());
>
> Now when I'm trying to search the index, I only get the values of the column text (default field name).
> Searcher searcher = new IndexSearcher(DIR);
> QueryParser qp = new QueryParser("text", new StandardAnalyzer());
> Query query = qp.parse("a*");
>
> How to query a search engine, if I want to get results from all indexed fields, not only default provided?
>
> Thanks in advance,
> Audrius
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Lucene DB indexing and searching Question (1.9.1)

Chris Hostetter-3

: You need to use MultiFieldQueryParser
:
: http://lucene.apache.org/java/docs/api/org/apache/lucene/queryParser/MultiFieldQueryParser.html

or put the text from all of your fields into one uber catchall field and
make that the default...

  foreach (column) {
     Field f = new Field(column.name, column.value);
     Field c = new Field("catchall", column.value);
     doc.add(f);
     doc.add(c);
  }



-Hoss


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]