@Override Query termsQuery(String field, List<Object> values) { int[] v = new int[values.size()]; int upTo = 0; for (int i = 0; i < values.size(); i++) { Object value = values.get(i); if (!hasDecimalPart(value)) { v[upTo++] = parse(value, true); } } if (upTo == 0) { return Queries.newMatchNoDocsQuery("All values have a decimal part"); } if (upTo != v.length) { v = Arrays.copyOf(v, upTo); } return IntPoint.newSetQuery(field, v); }
@Override FieldStats.Long stats(IndexReader reader, String fieldName, boolean isSearchable, boolean isAggregatable) throws IOException { FieldInfo fi = org.apache.lucene.index.MultiFields.getMergedFieldInfos(reader).fieldInfo(fieldName); if (fi == null) { return null; } long size = PointValues.size(reader, fieldName); if (size == 0) { return new FieldStats.Long(reader.maxDoc(), 0, -1, -1, isSearchable, isAggregatable); } int docCount = PointValues.getDocCount(reader, fieldName); byte[] min = PointValues.getMinPackedValue(reader, fieldName); byte[] max = PointValues.getMaxPackedValue(reader, fieldName); return new FieldStats.Long(reader.maxDoc(),docCount, -1L, size, isSearchable, isAggregatable, IntPoint.decodeDimension(min, 0), IntPoint.decodeDimension(max, 0)); }
public static void addDocument(Lucene lucene, String identifier, Map<String, Integer> keys, Map<String, String> fields) throws Exception { Document doc = new Document(); if (keys != null) for (String keyField : keys.keySet()) doc.add(new NumericDocValuesField(keyField, keys.get(keyField))); if (fields != null) { for (String fieldname : fields.keySet()) if (fieldname.equals("intField")) doc.add(new IntPoint(fieldname, Integer.parseInt(fields.get(fieldname)))); else { doc.add(new StringField(fieldname, fields.get(fieldname), Store.NO)); doc.add(new SortedDocValuesField(fieldname, new BytesRef(fields.get(fieldname)))); doc.add(new FacetField("cat_" + fieldname, fields.get(fieldname))); } } lucene.addDocument(identifier, doc); lucene.maybeCommitAfterUpdate(); }
@Test public void testIntRangeQuery() { JsonObject json = Json.createObjectBuilder() .add("query", Json.createObjectBuilder() .add("type", "RangeQuery") .add("rangeType", "Int") .add("field", "field") .add("lowerTerm", 1) .add("upperTerm", 5) .add("includeLower", JsonValue.FALSE) .add("includeUpper", JsonValue.TRUE)) .build(); QueryData q = new QueryData(new StringReader(json.toString()), queryConverter); Query query = IntPoint.newRangeQuery("field", 2, 5); assertEquals(query, q.query); }
@Test public void testIntRangeQueryWithNoBounds() { JsonObject json = Json.createObjectBuilder() .add("query", Json.createObjectBuilder() .add("type", "RangeQuery") .add("rangeType", "Int") .add("field", "field") .add("lowerTerm", JsonValue.NULL) .add("upperTerm", JsonValue.NULL) .add("includeLower", JsonValue.FALSE) .add("includeUpper", JsonValue.TRUE)) .build(); QueryData q = new QueryData(new StringReader(json.toString()), queryConverter); Query query = IntPoint.newRangeQuery("field", Integer.MIN_VALUE + 1, Integer.MAX_VALUE); assertEquals(query, q.query); }
@Override Query termQuery(String field, Object value) { if (hasDecimalPart(value)) { return Queries.newMatchNoDocsQuery("Value [" + value + "] has a decimal part"); } int v = parse(value, true); return IntPoint.newExactQuery(field, v); }
@Override Query rangeQuery(String field, Object lowerTerm, Object upperTerm, boolean includeLower, boolean includeUpper, boolean hasDocValues) { int l = Integer.MIN_VALUE; int u = Integer.MAX_VALUE; if (lowerTerm != null) { l = parse(lowerTerm, true); // if the lower bound is decimal: // - if the bound is positive then we increment it: // if lowerTerm=1.5 then the (inclusive) bound becomes 2 // - if the bound is negative then we leave it as is: // if lowerTerm=-1.5 then the (inclusive) bound becomes -1 due to the call to longValue boolean lowerTermHasDecimalPart = hasDecimalPart(lowerTerm); if ((lowerTermHasDecimalPart == false && includeLower == false) || (lowerTermHasDecimalPart && signum(lowerTerm) > 0)) { if (l == Integer.MAX_VALUE) { return new MatchNoDocsQuery(); } ++l; } } if (upperTerm != null) { u = parse(upperTerm, true); boolean upperTermHasDecimalPart = hasDecimalPart(upperTerm); if ((upperTermHasDecimalPart == false && includeUpper == false) || (upperTermHasDecimalPart && signum(upperTerm) < 0)) { if (u == Integer.MIN_VALUE) { return new MatchNoDocsQuery(); } --u; } } Query query = IntPoint.newRangeQuery(field, l, u); if (hasDocValues) { Query dvQuery = SortedNumericDocValuesField.newRangeQuery(field, l, u); query = new IndexOrDocValuesQuery(query, dvQuery); } return query; }
@Override public List<Field> createFields(String name, Number value, boolean indexed, boolean docValued, boolean stored) { List<Field> fields = new ArrayList<>(); if (indexed) { fields.add(new IntPoint(name, value.intValue())); } if (docValued) { fields.add(new SortedNumericDocValuesField(name, value.intValue())); } if (stored) { fields.add(new StoredField(name, value.intValue())); } return fields; }
public void testQueryFiltering() throws IOException { testCase(IntPoint.newRangeQuery("number", 0, 5), iw -> { iw.addDocument(Arrays.asList(new IntPoint("number", 7), new SortedNumericDocValuesField("number", 7))); iw.addDocument(Arrays.asList(new IntPoint("number", 1), new SortedNumericDocValuesField("number", 1))); }, max -> { assertEquals(1, max.getValue(), 0); }); }
public void testQueryFiltersAll() throws IOException { testCase(IntPoint.newRangeQuery("number", -1, 0), iw -> { iw.addDocument(Arrays.asList(new IntPoint("number", 7), new SortedNumericDocValuesField("number", 7))); iw.addDocument(Arrays.asList(new IntPoint("number", 1), new SortedNumericDocValuesField("number", 1))); }, max -> { assertEquals(Double.NEGATIVE_INFINITY, max.getValue(), 0); }); }
public void testQueryFiltering() throws IOException { testCase(IntPoint.newRangeQuery("number", 0, 3), iw -> { iw.addDocument(Arrays.asList(new IntPoint("number", 7), new SortedNumericDocValuesField("number", 7))); iw.addDocument(Arrays.asList(new IntPoint("number", 1), new SortedNumericDocValuesField("number", 2))); iw.addDocument(Arrays.asList(new IntPoint("number", 3), new SortedNumericDocValuesField("number", 3))); }, avg -> { assertEquals(2.5, avg.getValue(), 0); }); }
public void testQueryFiltersAll() throws IOException { testCase(IntPoint.newRangeQuery("number", -1, 0), iw -> { iw.addDocument(Arrays.asList(new IntPoint("number", 7), new SortedNumericDocValuesField("number", 7))); iw.addDocument(Arrays.asList(new IntPoint("number", 1), new SortedNumericDocValuesField("number", 2))); iw.addDocument(Arrays.asList(new IntPoint("number", 3), new SortedNumericDocValuesField("number", 7))); }, avg -> { assertEquals(Double.NaN, avg.getValue(), 0); }); }
public void testQueryFiltering() throws IOException { testCase(IntPoint.newRangeQuery("level", 0, 5), ValueType.STRING, iw -> { iw.addDocument(Arrays.asList(new IntPoint("level", 0), new SortedDocValuesField(FIELD_NAME, new BytesRef("foo")))); iw.addDocument(Arrays.asList(new IntPoint("level", 1), new SortedDocValuesField(FIELD_NAME, new BytesRef("bar")))); iw.addDocument(Arrays.asList(new IntPoint("level", 3), new SortedDocValuesField(FIELD_NAME, new BytesRef("foo")))); iw.addDocument(Arrays.asList(new IntPoint("level", 5), new SortedDocValuesField(FIELD_NAME, new BytesRef("baz")))); iw.addDocument(Arrays.asList(new IntPoint("level", 7), new SortedDocValuesField(FIELD_NAME, new BytesRef("baz")))); }, count -> assertEquals(4L, count.getValue())); }
public void testToQueryNumericField() throws IOException { assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0); Query parsedQuery = rangeQuery(INT_FIELD_NAME).from(23).to(54).includeLower(true).includeUpper(false).toQuery(createShardContext()); // since age is automatically registered in data, we encode it as numeric assertThat(parsedQuery, instanceOf(IndexOrDocValuesQuery.class)); parsedQuery = ((IndexOrDocValuesQuery) parsedQuery).getIndexQuery(); assertThat(parsedQuery, instanceOf(PointRangeQuery.class)); assertEquals(IntPoint.newRangeQuery(INT_FIELD_NAME, 23, 53), parsedQuery); }
public void testIntegerTermsQueryWithDecimalPart() { MappedFieldType ft = new NumberFieldMapper.NumberFieldType(NumberType.INTEGER); ft.setName("field"); ft.setIndexOptions(IndexOptions.DOCS); assertEquals(IntPoint.newSetQuery("field", 1), ft.termsQuery(Arrays.asList(1, 2.1), null)); assertEquals(IntPoint.newSetQuery("field", 1), ft.termsQuery(Arrays.asList(1.0, 2.1), null)); assertTrue(ft.termsQuery(Arrays.asList(1.1, 2.1), null) instanceof MatchNoDocsQuery); }
/** * Filter variations by positions, using only variation's start index * @param builder */ private void addPositionFilter(BooleanQuery.Builder builder) { if (startIndex != null && endIndex != null) { builder.add(IntPoint.newRangeQuery(FeatureIndexFields.START_INDEX.getFieldName(), startIndex, endIndex), BooleanClause.Occur.MUST); } else { if (startIndex != null) { builder.add(IntPoint.newRangeQuery(FeatureIndexFields.START_INDEX.getFieldName(), startIndex, Integer .MAX_VALUE), BooleanClause.Occur.MUST); } else if (endIndex != null) { builder.add(IntPoint.newRangeQuery(FeatureIndexFields.START_INDEX.getFieldName(), Integer.MIN_VALUE, endIndex), BooleanClause.Occur.MUST); } } }
private void addAdditionalFilter(BooleanQuery.Builder builder, Map.Entry<String, Object> entry) { String key = entry.getKey().toLowerCase(); if (entry.getValue() instanceof List) { addFiltersFromList(builder, entry, key); } else if (entry.getValue() instanceof Integer || entry.getValue() instanceof Long) { builder.add(IntPoint.newExactQuery(key, (Integer) entry.getValue()), BooleanClause.Occur.MUST); } else if (entry.getValue() instanceof Float || entry.getValue() instanceof Double) { builder.add(FloatPoint.newExactQuery(key, (Float) entry.getValue()), BooleanClause.Occur.MUST); } else { builder.add(new TermQuery(new Term(key, entry.getValue().toString().toLowerCase())), BooleanClause.Occur.MUST); } }
private void tryAddIntegralKeyValueFilter(BooleanQuery.Builder builder, Map.Entry<String, Object> entry, String key, List list, Object val) { if (val instanceof Integer || entry.getValue() instanceof Long) { builder.add(IntPoint.newRangeQuery(key, list.get(0) != null ? (Integer) list.get(0) : Integer.MIN_VALUE, list.get(1) != null ? (Integer) list.get(1) : Integer.MAX_VALUE), BooleanClause.Occur.MUST); } }
private void tryAddIntegeralFilter(BooleanQuery.Builder builder, Map.Entry<String, Object> entry, String key, Object val) { if (val instanceof Integer || entry.getValue() instanceof Long) { builder.add(IntPoint.newExactQuery(key, (Integer) entry.getValue()), BooleanClause.Occur.MUST); } }
@Nonnull public ESuccess deleteEntry (@Nonnull final IParticipantIdentifier aParticipantID, @Nonnull final PDDocumentMetaData aMetaData) throws IOException { ValueEnforcer.notNull (aParticipantID, "ParticipantID"); ValueEnforcer.notNull (aMetaData, "MetaData"); return m_aLucene.runAtomic ( () -> { final ICommonsList <Document> aDocuments = new CommonsArrayList <> (); // Get all documents to be marked as deleted final IndexSearcher aSearcher = m_aLucene.getSearcher (); if (aSearcher != null) { // Main searching final Query aQuery = new TermQuery (PDField.PARTICIPANT_ID.getExactMatchTerm (aParticipantID)); _timedSearch ( () -> aSearcher.search (aQuery, new AllDocumentsCollector (m_aLucene, (aDoc, nDocID) -> aDocuments.add (aDoc))), aQuery); } if (!aDocuments.isEmpty ()) { // Mark document as deleted aDocuments.forEach (aDocument -> aDocument.add (new IntPoint (CPDStorage.FIELD_DELETED, 1))); // Update the documents m_aLucene.updateDocuments (PDField.PARTICIPANT_ID.getExactMatchTerm (aParticipantID), aDocuments); } s_aLogger.info ("Marked " + aDocuments.size () + " Lucene documents as deleted"); AuditHelper.onAuditExecuteSuccess ("pd-indexer-delete", aParticipantID.getURIEncoded (), Integer.valueOf (aDocuments.size ()), aMetaData); }); }
private static void addDoc(IndexWriter w, String title, String uid) throws IOException { Document doc = new Document(); doc.add(new TextField("title", title, Field.Store.YES)); doc.add(new TextField("uid", uid, Field.Store.YES)); doc.add(new StringField("uid", uid, Field.Store.YES)); doc.add(new IntPoint("testIntField", 3)); long date = System.currentTimeMillis(); doc.add(new LongPoint("date", date)); doc.add(new NumericDocValuesField("date", date)); doc.add(new SortedSetDocValuesField("category", new BytesRef("Anything"))); Term uidTerm = new Term("uid", uid); w.updateDocument(uidTerm, doc); }
private Query createRangeQuery(JsonObject query) { String field = query.getString("field"); boolean includeLower = query.getBoolean("includeLower"); boolean includeUpper = query.getBoolean("includeUpper"); boolean lower = query.get("lowerTerm") != JsonValue.NULL; boolean upper = query.get("upperTerm") != JsonValue.NULL; switch (query.getString("rangeType")) { case "String": return TermRangeQuery.newStringRange(field, lower ? query.getString("lowerTerm") : null, upper ? query.getString("upperTerm") : null, includeLower, includeUpper); case "Int": Integer iLowerValue = lower ? query.getInt("lowerTerm") : Integer.MIN_VALUE; Integer iUpperValue = upper ? query.getInt("upperTerm") : Integer.MAX_VALUE; if (!includeLower && iLowerValue != null) iLowerValue += 1; if (!includeUpper && iUpperValue != null) iUpperValue -= 1; return IntPoint.newRangeQuery(field, iLowerValue, iUpperValue); case "Long": Long lLowerValue = lower ? query.getJsonNumber("lowerTerm").longValue() : Long.MIN_VALUE; Long lUpperValue = upper ? query.getJsonNumber("upperTerm").longValue() : Long.MAX_VALUE; if (!includeLower && lLowerValue != null) lLowerValue += 1; if (!includeUpper && lUpperValue != null) lUpperValue -= 1; return LongPoint.newRangeQuery(field, lLowerValue, lUpperValue); case "Double": Double dLowerValue = lower ? query.getJsonNumber("lowerTerm").doubleValue() : Double.NEGATIVE_INFINITY; Double dUpperValue = upper ? query.getJsonNumber("upperTerm").doubleValue() : Double.POSITIVE_INFINITY; if (!includeLower && dLowerValue != null) dLowerValue = Math.nextUp(dLowerValue); if (!includeUpper && dUpperValue != null) dUpperValue = Math.nextDown(dUpperValue); return DoublePoint.newRangeQuery(field, dLowerValue, dUpperValue); } return null; }
@Test public void testIntField() { JsonArray json = Json.createArrayBuilder() .add(Json.createObjectBuilder() .add("type", "IntField") .add("name", "name") .add("value", 1)) .build(); Document result = convert(json.toString()); assertEquals(new IntPoint("name", 1).fieldType(), result.getField("name").fieldType()); assertEquals(1, result.getField("name").numericValue().intValue()); }
@Test public void testStoredIntField() { JsonArray json = Json.createArrayBuilder() .add(Json.createObjectBuilder() .add("type", "IntField") .add("name", "name") .add("value", 1) .add("stored", JsonValue.TRUE)) .build(); Document result = convert(json.toString()); IndexableField[] fields = result.getFields("name"); assertEquals(new StoredField("name", 1).fieldType(), fields[0].fieldType()); assertEquals(new IntPoint("name", 1).fieldType(), fields[1].fieldType()); assertEquals(1, result.getField("name").numericValue().intValue()); }
public void testQueryFiltersAll() throws IOException { testCase(IntPoint.newRangeQuery("level", -1, 0), ValueType.STRING, iw -> { iw.addDocument(Arrays.asList(new IntPoint("level", 3), new SortedDocValuesField(FIELD_NAME, new BytesRef("foo")))); iw.addDocument(Arrays.asList(new IntPoint("level", 5), new SortedDocValuesField(FIELD_NAME, new BytesRef("baz")))); }, count -> assertEquals(0L, count.getValue())); }
public IndexSearchResult<FeatureIndexEntry> searchFeaturesInInterval(List<? extends FeatureFile> files, int start, int end, Chromosome chromosome) throws IOException { List<? extends FeatureFile> indexedFiles = files.stream().filter(f -> fileManager.indexForFeatureFileExists(f)) .collect(Collectors.toList()); if (indexedFiles.isEmpty()) { return new IndexSearchResult<>(Collections.emptyList(), false, 0); } SimpleFSDirectory[] indexes = fileManager.getIndexesForFiles(files); try (MultiReader reader = openMultiReader(indexes)) { if (reader.numDocs() == 0) { return new IndexSearchResult<>(Collections.emptyList(), false, 0); } BooleanQuery.Builder mainBuilder = new BooleanQuery.Builder(); Query chrQuery = new TermQuery(new Term(FeatureIndexFields.CHROMOSOME_ID.getFieldName(), new BytesRef(chromosome.getId().toString()))); mainBuilder.add(chrQuery, BooleanClause.Occur.MUST); BooleanQuery.Builder featureTypeBuilder = new BooleanQuery.Builder(); featureTypeBuilder.add(new TermQuery(new Term(FeatureIndexFields.FEATURE_TYPE.getFieldName(), FeatureType.GENE.getFileValue())), BooleanClause.Occur.SHOULD); featureTypeBuilder.add(new TermQuery(new Term(FeatureIndexFields.FEATURE_TYPE.getFieldName(), FeatureType.EXON.getFileValue())), BooleanClause.Occur.SHOULD); mainBuilder.add(featureTypeBuilder.build(), BooleanClause.Occur.MUST); BooleanQuery.Builder rangeBuilder = new BooleanQuery.Builder(); //start in interval Query startQuery = IntPoint.newRangeQuery(FeatureIndexFields.START_INDEX.getFieldName(), start, end); rangeBuilder.add(startQuery, BooleanClause.Occur.SHOULD); //end in interval Query endQuery = IntPoint.newRangeQuery(FeatureIndexFields.END_INDEX.getFieldName(), start, end); rangeBuilder.add(endQuery, BooleanClause.Occur.SHOULD); //feature lasts along all the interval (start < range and end > range) BooleanQuery.Builder spanQueryBuilder = new BooleanQuery.Builder(); Query startExtQuery = IntPoint.newRangeQuery(FeatureIndexFields.START_INDEX.getFieldName(), 0, start - 1); spanQueryBuilder.add(startExtQuery, BooleanClause.Occur.MUST); Query endExtQuery = IntPoint.newRangeQuery(FeatureIndexFields.END_INDEX.getFieldName(), end + 1, Integer.MAX_VALUE); spanQueryBuilder.add(endExtQuery, BooleanClause.Occur.MUST); rangeBuilder.add(spanQueryBuilder.build(), BooleanClause.Occur.SHOULD); mainBuilder.add(rangeBuilder.build(), BooleanClause.Occur.MUST); return searchFileIndexes(files, mainBuilder.build(), null, reader.numDocs(), null); } finally { for (SimpleFSDirectory index : indexes) { IOUtils.closeQuietly(index); } } }
@Test public void test2Query() throws IOException, ParseException { IndexReader indexReader = DirectoryReader.open(directory); StandardAnalyzer analyzer = new StandardAnalyzer(); QueryParser qp = new QueryParser("title", analyzer) { @Override protected Query getRangeQuery(final String fieldName, final String start, final String end, final boolean startInclusive, final boolean endInclusive) throws ParseException { if ("testIntField".equals(fieldName)) { int startInt = Integer.parseInt(start); int endInt = Integer.parseInt(end); if (!startInclusive) { startInt += 1; } if (!endInclusive) { endInt -= 1; } return IntPoint.newRangeQuery(fieldName, startInt, endInt); } // return default return super.getRangeQuery(fieldName, start, end, startInclusive, endInclusive); } @Override protected Query newTermQuery(org.apache.lucene.index.Term term) { String field = term.field(); String text = term.text(); if ("testIntField".equals(field)) { int value = Integer.parseInt(text); return IntPoint.newExactQuery(field, value); } return super.newTermQuery(term); } }; qp.setAllowLeadingWildcard(true); int hits; hits = runQuery(indexReader, qp, "java", 10); assertEquals("Expected 2 hits", 2, hits); hits = runQuery(indexReader, qp, "perl", 10); assertEquals("Expected 0 hits", 0, hits); hits = runQuery(indexReader, qp, "treatment", 10); assertEquals("Expected 0 hits", 0, hits); hits = runQuery(indexReader, qp, "long", 10); assertEquals("Expected 2 hits", 2, hits); hits = runQuery(indexReader, qp, "MongoDB", 10); assertEquals("Expected 1 hit", 1, hits); hits = runQuery(indexReader, qp, "java AND awesome", 10); assertEquals("Expected 1 hit", 1, hits); hits = runQuery(indexReader, qp, "testIntField:1", 10); assertEquals("Expected 0 hits", 0, hits); hits = runQuery(indexReader, qp, "testIntField:3", 10); assertEquals("Expected 5 hits", 5, hits); hits = runQuery(indexReader, qp, "testIntField:[1 TO 10]", 10); assertEquals("Expected 5 hits", 5, hits); indexReader.close(); }
@Override protected Field createField(Number o, String indexedFieldName) { return new IntPoint(indexedFieldName, o.intValue()); }
private List<IndexableField> createFields(JsonObject jsonField) throws IOException { String name = jsonField.getString("name"); List<IndexableField> fields = new ArrayList<>(); switch (jsonField.getString("type")) { case "StringField": String stringValue = jsonField.getString("value"); if (jsonField.getBoolean("sort", false)) { fields.add(new SortedDocValuesField(name, new BytesRef(stringValue))); } else { boolean stored = jsonField.getBoolean("stored", false); fields.add(new Field(name, stringValue, maybeAddTermVectors(jsonField, stored ? StringField.TYPE_STORED : StringField.TYPE_NOT_STORED))); } break; case "TextField": fields.add(new Field(name, jsonField.getString("value"), maybeAddTermVectors(jsonField, TextField.TYPE_NOT_STORED))); break; case "NoTermsFrequencyField": fields.add(new Field(name, jsonField.getString("value"), NO_TERMS_FREQUENCY_FIELD)); break; case "IntPoint": case "IntField": // for backwards compatibility int intValue = jsonField.getInt("value"); if (jsonField.getBoolean("sort", false)) { fields.add(new NumericDocValuesField(name, intValue)); } else { if (jsonField.getBoolean("stored", false)) fields.add(new StoredField(name, intValue)); fields.add(new IntPoint(name, intValue)); } break; case "DoublePoint": case "DoubleField": // for backwards compatibility double doubleValue = jsonField.getJsonNumber("value").doubleValue(); if (jsonField.getBoolean("sort", false)) { fields.add(new NumericDocValuesField(name, NumericUtils.doubleToSortableLong(doubleValue))); } else { if (jsonField.getBoolean("stored", false)) fields.add(new StoredField(name, doubleValue)); fields.add(new DoublePoint(name, doubleValue)); } break; case "LongPoint": case "LongField": // for backwards compatibility long longValue = jsonField.getJsonNumber("value").longValue(); if (jsonField.getBoolean("sort", false)) { fields.add(new NumericDocValuesField(name, longValue)); } else { if (jsonField.getBoolean("stored", false)) fields.add(new StoredField(name, longValue)); fields.add(new LongPoint(name, longValue)); } break; case "NumericField": fields.add(new NumericDocValuesField(name, jsonField.getJsonNumber("value").longValue())); break; case "KeyField": int value; if (jsonField.get("value").getValueType().equals(ValueType.STRING)) { value = termNumerator.numerateTerm(jsonField.getString("value")); } else { value = jsonField.getInt("value"); } fields.add(new NumericDocValuesField(name, value)); break; case "FacetField": JsonArray jsonArray = jsonField.getJsonArray("path"); String[] path = new String[jsonArray.size()]; for (int i = 0; i < jsonArray.size(); i++) { path[i] = jsonArray.getString(i); } fields.add(new FacetField(name, path)); } return fields; }
/** * Return a filter to include only descriptions of the specified types. * @param types * @return */ public static Query forDescriptionType(int... types) { return IntPoint.newSetQuery(FIELD_DESCRIPTION_TYPE, types); }