Examples of TermsFilter


Examples of org.apache.lucene.queries.TermsFilter

            // we use all non child types, cause we don't know if its exact or not...
            List<BytesRef> typesValues = new ArrayList<>(types.size());
            for (String type : context.mapperService().types()) {
                typesValues.add(Uid.createUidAsBytes(type, bValue));
            }
            return new TermsFilter(names.indexName(), typesValues);
        }
    }
View Full Code Here

Examples of org.apache.lucene.queries.TermsFilter

                for (String type : types) {
                    bValues.add(Uid.createUidAsBytes(type, bValue));
                }
            }
        }
        return new TermsFilter(names.indexName(), bValues);
    }
View Full Code Here

Examples of org.apache.lucene.queries.TermsFilter

    @Override
    public Filter termFilter(Object value, @Nullable QueryParseContext context) {
        if (fieldType.indexOptions() != IndexOptions.NONE || context == null) {
            return super.termFilter(value, context);
        }
        return new TermsFilter(UidFieldMapper.NAME, Uid.createTypeUids(context.queryTypes(), value));
    }
View Full Code Here

Examples of org.apache.lucene.queries.TermsFilter

    @Override
    public Filter termsFilter(List values, @Nullable QueryParseContext context) {
        if (fieldType.indexOptions() != IndexOptions.NONE || context == null) {
            return super.termsFilter(values, context);
        }
        return new TermsFilter(UidFieldMapper.NAME, Uid.createTypeUids(context.queryTypes(), values));
    }
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");
   
    try
    {
      TokenStream ts = analyzer.reusableTokenStream(fieldName, new StringReader(text));
      CharTermAttribute termAtt = ts.addAttribute(CharTermAttribute.class);
      Term term = null;
      ts.reset();
        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);
      }
      ts.end();
      ts.close();
    }
    catch (IOException ioe)
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 = 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));

    try
    {
      Token token = ts.next();
      Term term = null;
      while (token != null)
      {
        if (term == null)
        {
          term = new Term(fieldName, token.termText());
        } else
        {
//           create from previous to save fieldName.intern overhead
          term = term.createTerm(token.termText());
        }
        tf.addTerm(term);
        token = ts.next();
      }
    }
    catch (IOException ioe)
    {
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));

    try
    {
      Token token = ts.next();
      Term term = null;
      while (token != null)
      {
        if (term == null)
        {
          term = new Term(fieldName, token.termText());
        } else
        {
//           create from previous to save fieldName.intern overhead
          term = term.createTerm(token.termText());
        }
        tf.addTerm(term);
        token = ts.next();
      }
    }
    catch (IOException ioe)
    {
View Full Code Here

Examples of org.apache.lucene.search.TermsFilter

  /* (non-Javadoc)
   * @see org.apache.lucene.xmlparser.FilterBuilder#process(org.w3c.dom.Element)
   */
  public Filter getFilter(Element e) throws ParserException
  {
    TermsFilter tf=new TermsFilter();
    NodeList nl = e.getElementsByTagName("Field");
    for(int i=0;i<nl.getLength();i++)
    {
      Element fieldElem=(Element) nl.item(i);
      String fieldName=DOMUtils.getAttributeWithInheritance(fieldElem,"fieldName");
     
      if(fieldName==null)
      {
        throw new ParserException("TermsFilter missing \"fieldName\" element");       
      }
      String text=DOMUtils.getText(fieldElem).trim();
      TokenStream ts = analyzer.tokenStream(fieldName, new StringReader(text));
      try
      {
      Token token=ts.next();
      Term term=null;
      while(token!=null)
      {
        if(term==null)
        {
          term=new Term(fieldName,token.termText());
        }
        else
        {
          term=term.createTerm(token.termText()); //create from previous to save fieldName.intern overhead
        }
        tf.addTerm(term);
        token=ts.next();
      }
      }
      catch(IOException ioe)
      {
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));

    try
    {
      Token token = ts.next();
      Term term = null;
      while (token != null)
      {
        if (term == null)
        {
          term = new Term(fieldName, token.termText());
        } else
        {
//           create from previous to save fieldName.intern overhead
          term = term.createTerm(token.termText());
        }
        tf.addTerm(term);
        token = ts.next();
      }
    }
    catch (IOException ioe)
    {
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.