Package org.apache.lucene.search

Examples of org.apache.lucene.search.PrefixFilter


      CacheQuery cacheQuery = Search.getSearchManager(cache).getQuery(luceneQuery);
      List<Object> found = cacheQuery.list();

      assert found.size() == 2;

      Filter filter = new PrefixFilter(new Term("blurb", "cheese"));

      cacheQuery.filter(filter);

      found = cacheQuery.list();
View Full Code Here


      CacheQuery cacheQuery = Search.getSearchManager(cache).getQuery(luceneQuery);
      List<Object> found = cacheQuery.list();

      assert found.size() == 2;

      Filter filter = new PrefixFilter(new Term("blurb", "cheese"));

      cacheQuery.filter(filter);

      found = cacheQuery.list();
View Full Code Here

      CacheQuery cacheQuery = Search.getSearchManager(cache).getQuery(luceneQuery);
      List<Object> found = cacheQuery.list();

      assert found.size() == 2;

      Filter filter = new PrefixFilter(new Term("blurb", "cheese"));

      cacheQuery.filter(filter);

      found = cacheQuery.list();
View Full Code Here

        return termFactory.createTerm(value);
    }

    @Override public Filter fieldFilter(String value) {
        if (index == Field.Index.NO) {
            return new PrefixFilter(UidFieldMapper.TERM_FACTORY.createTerm(Uid.typePrefix(value)));
        }
        return new TermFilter(termFactory.createTerm(value));
    }
View Full Code Here

                fieldName = smartNameFieldMappers.mapper().names().indexName();
                value = smartNameFieldMappers.mapper().indexedValue(value);
            }
        }

        Filter filter = new PrefixFilter(new Term(fieldName, value));

        if (cache) {
            filter = parseContext.cacheFilter(filter, cacheKey);
        }
View Full Code Here

      CacheQuery cacheQuery = Search.getSearchManager(cache).getQuery(luceneQuery);
      List<Object> found = cacheQuery.list();

      assert found.size() == 2;

      Filter filter = new PrefixFilter(new Term("blurb", "cheese"));

      cacheQuery.filter(filter);

      found = cacheQuery.list();
View Full Code Here

   * @param term term
   * @return prefix query
   */
  private Query newPrefixQuery(String fieldName, String term) {
    return this.getUseConstantScoreQuery()?
      new ConstantScoreQuery(new PrefixFilter(new Term(fieldName,term))):
      new PrefixQuery(new Term(fieldName,term));
  }
View Full Code Here

    }

    @Override
    public Filter termFilter(Object value, @Nullable QueryParseContext context) {
        if (fieldType.indexOptions() == IndexOptions.NONE) {
            return new PrefixFilter(new Term(UidFieldMapper.NAME, Uid.typePrefixAsBytes(BytesRefs.toBytesRef(value))));
        }
        return new TermFilter(names().createIndexNameTerm(BytesRefs.toBytesRef(value)));
    }
View Full Code Here

    public void testPrefiFilteredQueryBuilder() throws IOException {
        IndexQueryParserService queryParser = queryParser();
        Query parsedQuery = queryParser.parse(filteredQuery(termQuery("name.first", "shay"), prefixFilter("name.first", "sh"))).query();
        assertThat(parsedQuery, instanceOf(FilteredQuery.class));
        FilteredQuery filteredQuery = (FilteredQuery) parsedQuery;
        PrefixFilter prefixFilter = (PrefixFilter) filteredQuery.getFilter();
        assertThat(prefixFilter.getPrefix(), equalTo(new Term("name.first", "sh")));
    }
View Full Code Here

        IndexQueryParserService queryParser = queryParser();
        String query = copyToStringFromClasspath("/org/elasticsearch/index/query/prefix-filter.json");
        Query parsedQuery = queryParser.parse(query).query();
        assertThat(parsedQuery, instanceOf(FilteredQuery.class));
        FilteredQuery filteredQuery = (FilteredQuery) parsedQuery;
        PrefixFilter prefixFilter = (PrefixFilter) filteredQuery.getFilter();
        assertThat(prefixFilter.getPrefix(), equalTo(new Term("name.first", "sh")));
    }
View Full Code Here

TOP

Related Classes of org.apache.lucene.search.PrefixFilter

Copyright © 2018 www.massapicom. 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.