Package org.elasticsearch.index.query

Examples of org.elasticsearch.index.query.RangeFilterBuilder


        // message sync - update subscriber with the current timestamp
        service.checkpoint(subscriberId);
        service.flushCheckpoint();
        // there are unreceived messages, get all outstanding messages since last seen
        QueryBuilder queryBuilder = termQuery("topic", topic);
        RangeFilterBuilder filterBuilder = rangeFilter("timestamp").gte(lastSeen);
        SearchResponse searchResponse = client.prepareSearch()
                .setIndices(pubSubIndexName)
                .setTypes("publish")
                .setSearchType(SearchType.SCAN)
                .setScroll(scrollTimeout)
View Full Code Here


            val = val.substring(1, val.length() - 1);
            int index1 = val.indexOf(" ");
            if (index1 < 0)
                throw new IllegalStateException("couldn't handle filter " + key + ":" + val);

            RangeFilterBuilder rfb = FilterBuilders.rangeFilter(key);
            Object from = null;
            Object to = null;

            if (!val.startsWith("*") && !val.startsWith("-Infinity")) {
                try {
                    from = Integer.parseInt(val.substring(0, index1));
                } catch (NumberFormatException ex) {
                    from = Helper.toDate(val.substring(0, index1));
                }
                rfb.from(from).includeLower(true);
            }

            if (!val.endsWith("*") && !val.endsWith("Infinity")) {
                String tmp = val.substring(index1 + " TO ".length());
                try {
                    to = Integer.parseInt(tmp);
                } catch (NumberFormatException ex) {
                    to = Helper.toDate(tmp);
                }

                if (from != null)
                    rfb.to(to).includeUpper(true);
                else
                    rfb.lte(to);
            }

            if (from == null && to == null)
                return FilterBuilders.existsFilter(val);

View Full Code Here

    public void deleteUntil(Date removeUntil) {
        logger.info("Deleting tweets older than " + removeUntil);
        NotFilterBuilder notPersistentFilter = FilterBuilders.notFilter(FilterBuilders.existsFilter(UPDATE_DT));
        FilterBuilder fewRetweetsFilter = FilterBuilders.rangeFilter(RT_COUNT).lt(100).includeUpper(false);
        RangeFilterBuilder tooOldFilter = FilterBuilders.rangeFilter(DATE);
        tooOldFilter.lte(removeUntil);
        FilterBuilder filter = FilterBuilders.andFilter(tooOldFilter,
                notPersistentFilter, fewRetweetsFilter);

        client.prepareDeleteByQuery(getIndexName()).setTypes(getIndexType()).
                setQuery(QueryBuilders.filteredQuery(QueryBuilders.matchAllQuery(), filter)).
View Full Code Here

        searchSourceBuilder.filter(andFilterBuilder);
    }

    private void filterFutureResults(AndFilterBuilder filterBuilder) {
        String formattedDate = ISODateTimeFormat.dateTimeNoMillis().print(new Date().getTime());
        RangeFilterBuilder rangeFilterBuilder =
                new RangeFilterBuilder("publishAt").to(formattedDate).includeLower(true).includeUpper(true);

        filterBuilder.add(rangeFilterBuilder);
    }
View Full Code Here

     * description for a discussion of error codes.
     */
    @Override
    public int scan(String table, String startkey, int recordcount, Set<String> fields, Vector<HashMap<String, ByteIterator>> result) {
        try {
            final RangeFilterBuilder filter = rangeFilter("_id").gte(startkey);
            final SearchResponse response = client.prepareSearch(indexKey)
                    .setTypes(table)
                    .setQuery(matchAllQuery())
                    .setFilter(filter)
                    .setSize(recordcount)
View Full Code Here

        {
            filterBuilder = new TermFilterBuilder(name, value);
        }
        else if (condition.equals(">"))
        {
            filterBuilder = new RangeFilterBuilder(name).gt(value);
        }
        else if (condition.equals("<"))
        {
            filterBuilder = new RangeFilterBuilder(name).lt(value);
        }
        else if (condition.equals(">="))
        {
            filterBuilder = new RangeFilterBuilder(name).gte(value);
        }
        else if (condition.equals("<="))
        {
            filterBuilder = new RangeFilterBuilder(name).lte(value);
        }

        return filterBuilder;
    }
View Full Code Here

TOP

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

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.