Package org.elasticsearch.index.query

Examples of org.elasticsearch.index.query.FilterBuilder


     * @throws Exception
     * <br>See <a href="http://www.elasticsearch.org/guide/reference/query-dsl/range-filter.html">documentation</a>
     */
    @Test
    public void rangeFilter() throws Exception {
        FilterBuilder filter = FilterBuilders.rangeFilter("price")
                .from("1")
                .to("2")
                .includeLower(true)
                .includeUpper(false);

View Full Code Here


     * @throws Exception
     * <br>See <a href="http://www.elasticsearch.org/guide/reference/query-dsl/script-filter.html">documentation</a>
     */
    @Test
    public void scriptFilter() throws Exception {
        FilterBuilder filter = FilterBuilders.scriptFilter(
                "doc['price'].value > param1"
            ).addParam("param1", 5);

        launchSearch(filter);
    }
View Full Code Here

     * @throws Exception
     * <br>See <a href="http://www.elasticsearch.org/guide/reference/query-dsl/term-filter.html">documentation</a>
     */
    @Test
    public void termFilter() throws Exception {
        FilterBuilder filter = FilterBuilders.termFilter("brand", "heineken");

        launchSearch(filter);
    }
View Full Code Here

     * @throws Exception
     * <br>See <a href="http://www.elasticsearch.org/guide/reference/query-dsl/terms-filter.html">documentation</a>
     */
    @Test
    public void termsFilter() throws Exception {
        FilterBuilder filter = FilterBuilders.termsFilter("brand", "heineken", "kriek")
                .execution("plain"); // "bool", "and" or "or"

        launchSearch(filter);
    }
View Full Code Here

     * @throws Exception
     * <br>See <a href="http://www.elasticsearch.org/guide/reference/query-dsl/nested-filter.html">documentation</a>
     */
    @Test @Ignore
    public void nestedFilter() throws Exception {
        FilterBuilder filter = FilterBuilders.nestedFilter("obj1",
                QueryBuilders.boolQuery()
                        .must(QueryBuilders.matchQuery("obj1.name", "blue"))
                        .must(QueryBuilders.rangeQuery("obj1.count").gt(5))
        );
        launchSearch(filter);
View Full Code Here

        assertAcked(prepareCreate("test").addMapping("type", "user", "type=string"));

        ensureGreen();

        logger.info("--> aliasing index [test] with [alias1] and filter [user:kimchy]");
        FilterBuilder filter = termFilter("user", "kimchy");
        assertAcked(admin().indices().prepareAliases().addAlias("test", "alias1", filter));

        // For now just making sure that filter was stored with the alias
        logger.info("--> making sure that filter was stored with alias [alias1] and filter [user:kimchy]");
        ClusterState clusterState = admin().cluster().prepareState().get().getState();
View Full Code Here

                        QueryBuilders.matchQuery("brand", "HEINEKEN")
                )
                .must(
                        QueryBuilders.rangeQuery("price").from(5).to(10)
                );
        FilterBuilder filter = FilterBuilders.rangeFilter("size").from(1);
        QueryBuilder qb = QueryBuilders.filteredQuery(query, filter);

        logger.info("Your query is : {}", qb);

        SearchResponse sr = node.client().prepareSearch("meal").setQuery(qb)
View Full Code Here

     * @throws Exception
     * <br>See <a href="http://www.elasticsearch.org/guide/reference/api/search/facets/terms-facet.html">documentation</a>
     */
    @Test
    public void sameFilterOnTermFacet() throws Exception {
        FilterBuilder filter = FilterBuilders.termFilter("colour", "pale");

        TermsFacetBuilder facet = FacetBuilders.termsFacet("f")
                .field("brand")
                .facetFilter(filter);

View Full Code Here

  public <P extends ParaObject> List<P> findTerms(String appid, String type,
      Map<String, ?> terms, boolean mustMatchAll, Pager... pager) {
    if (terms == null || terms.isEmpty()) {
      return new ArrayList<P>();
    }
    FilterBuilder fb = null;
    boolean noop = true;
    if (terms.size() == 1) {
      String field = terms.keySet().iterator().next();
      if (!StringUtils.isBlank(field) && terms.get(field) != null) {
        fb = FilterBuilders.termFilter(field, terms.get(field));
View Full Code Here

      String[] fields, String liketext, Pager... pager) {
    if (StringUtils.isBlank(liketext)) {
      return new ArrayList<P>();
    }
    QueryBuilder qb;
    FilterBuilder fb;

    if (fields == null || fields.length == 0) {
      qb = QueryBuilders.moreLikeThisQuery().likeText(liketext).minDocFreq(1).minTermFreq(1);
    } else {
      qb = QueryBuilders.moreLikeThisQuery(fields).likeText(liketext).minDocFreq(1).minTermFreq(1);
View Full Code Here

TOP

Related Classes of org.elasticsearch.index.query.FilterBuilder

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.