There are a number of ways of doing this. One way I would suggest if simply to 
store the CONTENTS fields and prefix it with the field name. So instead of 
storing a single CONTENTS field for a document, store a CONTENTS field for each 
other field with the field name prefixing each field value. E.g.

If you have a document with 3 paragraphs instead of storing a single CONTENTS 
field with the append value of all three paragraphs store 3 contents fields the 
first with the value prefixed by "p1" the second by "p2" etc.

An alternative would be not to have a contents field and to write a query 
parser that decode a search for X to search for field1:X OR field2:X OR 
field3:X etc. then use explain to try and track down why it was a hit.

Mike

www.ardentia.com the home of NetSearch

-----Original Message-----
From: Gwyn Carwardine [mailto:[EMAIL PROTECTED] 
Sent: 30 January 2006 11:23
To: java-user@lucene.apache.org
Subject: RE: Searching over more than one Fields

I was happy to take the hit of storing the text twice.

I have created an aggregate field called "CONTENTS" that has all the other
fields concatenated together.
I also created a list of the other fields (because they can vary from doc to
doc) in another field "FIELDLIST"

I search this field and for any hits I get I retrieve the list of fields
from FIELDLIST and then go through retrieving each field in the list. For
each field I can then put it through the highlighter and if there are any
results I must have had a hit in that field so I display it.

What I wanted to achieve was to be able to search all fields in the document
(using the aggregate field) but when retrieving actually be able to find the
particular fields that had matches. Your requirements may be different!

-Gwyn

-----Original Message-----
From: Jairo Sánchez Menéndez [mailto:[EMAIL PROTECTED] 
Sent: 29 January 2006 18:18
To: java-user@lucene.apache.org
Subject: Searching over more than one Fields

Hi everybody,

Well I will explain you my problem:
I am indexing ".txt" files and basically I split each file in 
paragraphs, I mean, i create a Document for each file and within this 
Document I
add one Field named "px" for each paragraph (x) of the file.
My question is: after creating the index, now i want to do searches over 
the index, but what I want is searching a word over all paragraphs of 
all files, i.e.
searching the word in all Fields of all Documents.
I am using something like this, but doing so i can only put p1 or p2 or 
p3 ... in the Field parameter of the parse method, how can i search over 
all paragraphs??
Query query=QueryParser.parse(q, "   ", new WhitespaceAnalyzer());
Hits hits=is.search(query);

Thanks.

                
______________________________________________ 
LLama Gratis a cualquier PC del Mundo. 
Llamadas a fijos y móviles desde 1 céntimo por minuto. 
http://es.voice.yahoo.com

---------------------------------------------------------------------
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]

Reply via email to