Qizx/open API

net.axyana.qizxopen.dm
Class FulltextQuery

java.lang.Object
  extended bynet.axyana.qizxopen.dm.FulltextQuery

public class FulltextQuery
extends java.lang.Object

Full-text queries: parsing, search in fall-back mode (without indexes), term highlighting.

A query is a AND of required and excluded clauses. A clause is a phrase or an alternative of terms. A term is a simple word, a word with wildcards (a la Unix) or an approximate word (uses a generic Soundex-like phonetic algorithm).

Syntax:

  	query -> clause [ ['AND' | '&']?  ['NOT' | '-']?  clause]*
  	clause -> ORterm | phrase
  	phrase -> '"' term+ '"' distance?  |  '\'' term+ '\'' distance?
  	ORterm -> term [ ['OR' | '|'] term]* 
 	term -> [ wordchar | '*' | '?' ]+ distance? 
  	distance -> '~' integer?
  


Nested Class Summary
static class FulltextQuery.Clause
          Abstract clause.
 class FulltextQuery.Hiliter
          Defines the way highlighted words are decorated: a highlighted word is surrounded by an element of the form word, where N is the rank of the fulltext clause (phrase or alternative of terms), E is the 'element' field of this hiliter (a QName with default value "span"), A is the 'attribute' field (a QName with default value "class"), and pattern is a string prefix to the attribute value (by default empty).
static class FulltextQuery.ParseException
           
static class FulltextQuery.Phrase
          Sequence of terms, with an optional total spacing between terms.
static class FulltextQuery.Term
          A simple word or a pattern.
static class FulltextQuery.TermOr
          Union of terms.
 
Field Summary
 FulltextQuery.Clause[] excluded
           
 FulltextQuery.Clause[] required
           
 WordSifter wordSifter
           
 
Constructor Summary
FulltextQuery()
           
 
Method Summary
 void highlight(Node fragment, FulltextQuery.Hiliter hiliter, XMLEventReceiver result)
          Highlighting matching nodes inside a document fragment with hiliter patterns.
 boolean matches(Node node)
          Tells whether the text contents of the node matches this query.
static FulltextQuery parsePhrase(java.lang.String query, int distance, WordSifter sifter)
          Parses and builds a phrase query: simple sequence of terms without quotes.
static FulltextQuery parseQuery(java.lang.String query, WordSifter sifter)
          Parses and builds a general FulltextQuery.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

required

public FulltextQuery.Clause[] required

excluded

public FulltextQuery.Clause[] excluded

wordSifter

public WordSifter wordSifter
Constructor Detail

FulltextQuery

public FulltextQuery()
Method Detail

toString

public java.lang.String toString()

parseQuery

public static FulltextQuery parseQuery(java.lang.String query,
                                       WordSifter sifter)
                                throws FulltextQuery.ParseException
Parses and builds a general FulltextQuery.

Parameters:
query - parsed query expression.
sifter - used for extracting and normalizing terms.
Throws:
FulltextQuery.ParseException

parsePhrase

public static FulltextQuery parsePhrase(java.lang.String query,
                                        int distance,
                                        WordSifter sifter)
                                 throws FulltextQuery.ParseException
Parses and builds a phrase query: simple sequence of terms without quotes.

Parameters:
query - parsed query expression.
distance - maximum number of interspersed words (0 for exact phrase).
sifter - used for extracting and normalizing terms.
Throws:
FulltextQuery.ParseException

matches

public boolean matches(Node node)
Tells whether the text contents of the node matches this query.


highlight

public void highlight(Node fragment,
                      FulltextQuery.Hiliter hiliter,
                      XMLEventReceiver result)
               throws DataModelException
Highlighting matching nodes inside a document fragment with hiliter patterns.

Parameters:
fragment - source document fragment
hiliter - defines the way highlighted words are decorated (see FulltextQuery.Hiliter).
result - hilighted output.
Throws:
DataModelException

© 2005 Axyana Software