Examples of TermsFilter


Examples of org.apache.lucene.search.TermsFilter

   *
   * @see org.apache.lucene.xmlparser.FilterBuilder#process(org.w3c.dom.Element)
   */
  public Filter getFilter(Element e) throws ParserException
  {
    TermsFilter tf = new TermsFilter();
    String text = DOMUtils.getNonBlankTextOrFail(e);
    String fieldName = DOMUtils.getAttributeWithInheritanceOrFail(e, "fieldName");
    TokenStream ts = analyzer.tokenStream(fieldName, new StringReader(text));

    try
    {
                  final Token reusableToken = new Token();
      Term term = null;
                  for (Token nextToken = ts.next(reusableToken); nextToken != null; nextToken = ts.next(reusableToken)) {
        if (term == null)
        {
          term = new Term(fieldName, nextToken.term());
        } else
        {
//           create from previous to save fieldName.intern overhead
          term = term.createTerm(nextToken.term());
        }
        tf.addTerm(term);
      }
    }
    catch (IOException ioe)
    {
      throw new RuntimeException("Error constructing terms from index:"
View Full Code Here

Examples of org.apache.lucene.search.TermsFilter

   *
   * @see org.apache.lucene.xmlparser.FilterBuilder#process(org.w3c.dom.Element)
   */
  public Filter getFilter(Element e) throws ParserException
  {
    TermsFilter tf = new TermsFilter();
    String text = DOMUtils.getNonBlankTextOrFail(e);
    String fieldName = DOMUtils.getAttributeWithInheritanceOrFail(e, "fieldName");
    TokenStream ts = analyzer.tokenStream(fieldName, new StringReader(text));
    TermAttribute termAtt = (TermAttribute) ts.addAttribute(TermAttribute.class);
   
    try
    {
      Term term = null;
        while (ts.incrementToken()) {
        if (term == null)
        {
          term = new Term(fieldName, termAtt.term());
        } else
        {
//           create from previous to save fieldName.intern overhead
          term = term.createTerm(termAtt.term());
        }
        tf.addTerm(term);
      }
    }
    catch (IOException ioe)
    {
      throw new RuntimeException("Error constructing terms from index:"
View Full Code Here

Examples of org.apache.lucene.search.TermsFilter

   *
   * @see org.apache.lucene.xmlparser.FilterBuilder#process(org.w3c.dom.Element)
   */
  public Filter getFilter(Element e) throws ParserException
  {
    TermsFilter tf = new TermsFilter();
    String text = DOMUtils.getNonBlankTextOrFail(e);
    String fieldName = DOMUtils.getAttributeWithInheritanceOrFail(e, "fieldName");
    TokenStream ts = analyzer.tokenStream(fieldName, new StringReader(text));
    CharTermAttribute termAtt = ts.addAttribute(CharTermAttribute.class);
   
    try
    {
      Term term = null;
        while (ts.incrementToken()) {
        if (term == null)
        {
          term = new Term(fieldName, termAtt.toString());
        } else
        {
//           create from previous to save fieldName.intern overhead
          term = term.createTerm(termAtt.toString());
        }
        tf.addTerm(term);
      }
    }
    catch (IOException ioe)
    {
      throw new RuntimeException("Error constructing terms from index:"
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.