lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <hossman_luc...@fucit.org>
Subject RE: Searching API: QueryParser vs Programatic queries
Date Mon, 22 May 2006 21:54:07 GMT

: Not quite. The user is presented with a list of (UI) fields, and each
: field already knows whether its an "OR" "AND" etc.
: So, there is no query String as such.
: For this reason, it seems to make more sense to build the query up
: programmatically - as my field meta data can drive this.
: However, if I do that, I have to do the work of extracting terms by
: running through an analyser for each field manually.
: This is also done by the query parser.

typically, when build queries up from form data, each piece of data falls
into one of 2 categories:

  1) data which doesn't need analyzed because the field it's going to
     query on wasn't tokenized (ie: a date field, or a numeric field, or a
     boolean field)
  2) data whcih is typed by the user in a text box, and not only needs
     analyzed, but may also need some parsing (ie: to support "quoted
     phrases" or +mandatory and -prohibited terms)

in the first case, build your query clauses progromatically.

in the second case make a QueryParser on the fly with the defaultField set
to whatever makes sense and let it handle parsing the users text (and
applying hte correct analyzer using PerFieldAnalyzer.  if there are
special characters you want it to ignore, then escape them first.

i discussed this a little more recently...

http://www.nabble.com/RE%3A+Building+queries-t1635907.html#a4436416



-Hoss


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


Mime
View raw message