All sorted now. Of course, if I can loop through the properties of a
bean to add them as fields to the document, then I can certainly do the
same at query time to build the MultiFieldQueryParser. All done and
working great.
Thanks for all your comments.
digby wrote:
Basically, I've got a small app which allows me to update fields in
bunch of mysql tables using Hibernate. As I save each bean, I'm want to
add it to the lucene index aswell. However, I want the app to be as
generic as possible and at the moment it doesn't care what the bean is,
as long as there's a hibernate mapping, it will understand what to do.
When the user is searching for the bean, I want them to be able to
search over all the fields, but a) there will be lots of beans in the
index with many different fields (so I can't know which ones to search
for), and b) the user won't necessarily know the field names (so they
can't specify them).
Having said that, I've just realised I could loop through all the
properties defined in the hibernate mapping document and build up a
MultiFieldQueryParser, but just concatenating all the bean's properties
into a single field still seems like the easiest option (as well as
having the proper fields so they can search if they know the field name).
Digby
Michael D. Curtin wrote:
Not sure if I understand exactly what you want to do, but would the
"<field>:<keyword>" syntax that QueryParser understands work for you?
That is, you could send query text like
f1:foo f2:foo f3:foo
to search for "foo" in any of the 3 fields. If you need boolean
capabilities you can use parentheses, like so:
+(f1:foo f2:foo f3:foo) +(f1:bar f2:bar f3:bar)
to mean "foo in some field, and bar in some field", or
+(f1:foo f1:bar) +(f2:foo f2:bar) +(f3:foo f3:bar)
"foo or bar in all fields".
Would this work for ya?
--MDC
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]