org.elasticsearch.index.query.TermFilterBuilder Java Examples
The following examples show how to use
org.elasticsearch.index.query.TermFilterBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServicoRepository.java From portal-de-servicos with MIT License | 5 votes |
@Cacheable("servicos-por-area-de-interesse") default List<ServicoXML> findByAreaDeInteresse(AreaDeInteresse areaDeInteresse) { return search(new NativeSearchQueryBuilder() .withFilter(new TermFilterBuilder("areasDeInteresse", singletonList(areaDeInteresse))) .withSort(new FieldSortBuilder("nome").order(ASC)) .build()) .getContent(); }
Example #2
Source File: ServicoRepository.java From portal-de-servicos with MIT License | 5 votes |
@Cacheable("servicos-por-segmento-da-sociedade") default List<ServicoXML> findBySegmentoDaSociedade(SegmentoDaSociedade segmentoDaSociedade) { return search(new NativeSearchQueryBuilder() .withFilter(new TermFilterBuilder("segmentosDaSociedade", singletonList(segmentoDaSociedade))) .withSort(new FieldSortBuilder("nome").order(ASC)) .build()) .getContent(); }
Example #3
Source File: ProductQueryServiceImpl.java From elasticsearch-tutorial with MIT License | 4 votes |
private TermFilterBuilder getTermFilter(String fieldName, String fieldValue) { return FilterBuilders.termFilter(fieldName, fieldValue); }
Example #4
Source File: ProductQueryServiceImpl.java From searchanalytics-bigdata with MIT License | 4 votes |
private TermFilterBuilder getTermFilter(final String fieldName, final String fieldValue) { return FilterBuilders.termFilter(fieldName, fieldValue); }
Example #5
Source File: EsQueryVistor.java From usergrid with Apache License 2.0 | 4 votes |
@Override public void visit( Equal op ) throws NoIndexException { final String name = op.getProperty().getValue().toLowerCase(); final Object value = op.getLiteral().getValue(); //special case so we support our '*' char with wildcard, also should work for uuids if ( value instanceof String || value instanceof UUID ) { String stringValue = ((value instanceof String) ? (String)value : value.toString()).toLowerCase().trim(); // or field is just a string that does need a prefix us a query if ( stringValue.contains( "*" ) ) { //Because of our legacy behavior, where we match CCCC*, we need to use the unanalyzed string to ensure that //we start final WildcardQueryBuilder wildcardQuery = QueryBuilders.wildcardQuery( IndexingUtils.FIELD_STRING_NESTED_UNANALYZED, stringValue ); queryBuilders.push( fieldNameTerm( name, wildcardQuery ) ); filterBuilders.push( NoOpFilterBuilder.INSTANCE ); return; } // Usergrid query parser allows single quotes to be escaped in values if ( stringValue.contains("\\'")) { stringValue = stringValue.replace("\\'", "'"); } //it's an exact match, use a filter final TermFilterBuilder termFilter = FilterBuilders.termFilter( IndexingUtils.FIELD_STRING_NESTED_UNANALYZED, stringValue ); queryBuilders.push( NoOpQueryBuilder.INSTANCE ); filterBuilders.push( fieldNameTerm( name, termFilter ) ); return; } // assume all other types need prefix final TermFilterBuilder termQuery = FilterBuilders.termFilter(getFieldNameForType(value), sanitize(value)); filterBuilders.push( fieldNameTerm( name, termQuery ) ); queryBuilders.push( NoOpQueryBuilder.INSTANCE ); }
Example #6
Source File: SortBuilder.java From usergrid with Apache License 2.0 | 4 votes |
/** * Create a term filter for our sorts */ public static TermFilterBuilder sortPropertyTermFilter( final String propertyName ) { return FilterBuilders.termFilter( IndexingUtils.FIELD_NAME, propertyName ); }
Example #7
Source File: SearchRequestBuilderStrategy.java From usergrid with Apache License 2.0 | 3 votes |
/** * Create a sort for the property name and field name specified * * @param sortOrder The sort order * @param fieldName The name of the field for the type * @param propertyName The property name the user specified for the sort */ private FieldSortBuilder createSort( final SortOrder sortOrder, final String fieldName, final String propertyName ) { final TermFilterBuilder propertyFilter = sortPropertyTermFilter( propertyName ); return SortBuilders.fieldSort( fieldName ).order( sortOrder ).setNestedFilter( propertyFilter ); }
Example #8
Source File: EsQueryVistor.java From usergrid with Apache License 2.0 | 3 votes |
@Override public void visit( WithinOperand op ) { final String name = op.getProperty().getValue().toLowerCase(); float lat = op.getLatitude().getFloatValue(); float lon = op.getLongitude().getFloatValue(); float distance = op.getDistance().getFloatValue(); final FilterBuilder fb = FilterBuilders.geoDistanceFilter( IndexingUtils.FIELD_LOCATION_NESTED ).lat( lat ).lon( lon ) .distance( distance, DistanceUnit.METERS ); filterBuilders.push( fieldNameTerm( name, fb ) ); //create our geo-sort based off of this point specified //this geoSort won't has a sort on it final GeoDistanceSortBuilder geoSort = SortBuilders.geoDistanceSort( IndexingUtils.FIELD_LOCATION_NESTED ).unit( DistanceUnit.METERS ) .geoDistance(GeoDistance.SLOPPY_ARC).point(lat, lon); final TermFilterBuilder sortPropertyName = sortPropertyTermFilter(name); geoSort.setNestedFilter( sortPropertyName ); geoSortFields.addField(name, geoSort); //no op for query, push queryBuilders.push( NoOpQueryBuilder.INSTANCE ); }