field = new SortedSetDocValuesField( key, new BytesRef( value.toString() ) );
@Override protected void parseCreateField(ParseContext context, List<IndexableField> fields) throws IOException { if (fieldType().indexOptions() == IndexOptions.NONE && !fieldType().stored()) { return; } fields.add(new Field(fieldType().name(), context.sourceToParse().type(), fieldType())); if (fieldType().hasDocValues()) { fields.add(new SortedSetDocValuesField(fieldType().name(), new BytesRef(context.sourceToParse().type()))); } }
fields.add(new SortedSetDocValuesField(fieldType().name(), binaryValue));
@Override final void newField(final String fieldName, final Object value, final FieldConsumer consumer) { final Field field; if (value instanceof BytesRef) field = new SortedSetDocValuesField(fieldName, (BytesRef) value); else field = new SortedSetDocValuesField(fieldName, new BytesRef(value.toString())); consumer.accept(genericFieldName, fieldName, field); }
fields.add(new SortedSetDocValuesField(fieldType().name(), new BytesRef(InetAddressPoint.encode(address)))); } else if (fieldType().stored() || fieldType().indexOptions() != IndexOptions.NONE) { createFieldNamesField(context, fields);
/** {@inheritDoc} */ @Override public Optional<Field> sortedField(String name, String value) { BytesRef bytes = new BytesRef(value); validateTerm(name, bytes); return Optional.of(new SortedSetDocValuesField(name, bytes)); }
private Document buildDocument(BytesRef text, Set<BytesRef> contexts, long weight, BytesRef payload) throws IOException { String textString = text.utf8ToString(); Document doc = new Document(); FieldType ft = getTextFieldType(); doc.add(new Field(TEXT_FIELD_NAME, textString, ft)); doc.add(new Field("textgrams", textString, ft)); doc.add(new StringField(EXACT_TEXT_FIELD_NAME, textString, Field.Store.NO)); doc.add(new BinaryDocValuesField(TEXT_FIELD_NAME, text)); doc.add(new NumericDocValuesField("weight", weight)); if (payload != null) { doc.add(new BinaryDocValuesField("payloads", payload)); } if (contexts != null) { for(BytesRef context : contexts) { doc.add(new StringField(CONTEXTS_FIELD_NAME, context, Field.Store.NO)); doc.add(new SortedSetDocValuesField(CONTEXTS_FIELD_NAME, context)); } } return doc; }
private void processSSDVFacetFields(Map<String,List<SortedSetDocValuesFacetField>> byField, Document doc) throws IOException { //System.out.println("process SSDV: " + byField); for(Map.Entry<String,List<SortedSetDocValuesFacetField>> ent : byField.entrySet()) { String indexFieldName = ent.getKey(); //System.out.println(" field=" + indexFieldName); for(SortedSetDocValuesFacetField facetField : ent.getValue()) { FacetLabel cp = new FacetLabel(facetField.dim, facetField.label); String fullPath = pathToString(cp.components, cp.length); //System.out.println("add " + fullPath); // For facet counts: doc.add(new SortedSetDocValuesField(indexFieldName, new BytesRef(fullPath))); // For drill-down: doc.add(new StringField(indexFieldName, fullPath, Field.Store.NO)); doc.add(new StringField(indexFieldName, facetField.dim, Field.Store.NO)); } } }
@Override protected void onExecute(Document doc, XsObject root, XsObject current, LogicletContext ctx, ExecuteWatcher watcher) { String field = PropertiesConstants.transform(ctx, $field, ""); String value = PropertiesConstants.transform(ctx, $value, ""); if (StringUtils.isNotEmpty(field) && StringUtils.isNotEmpty(value)){ if (sorted){ doc.add(new SortedSetDocValuesField(field,new BytesRef(value))); if (store){ doc.add(new StringField(field,value,Field.Store.YES)); } }else{ doc.add(new StringField(field,value,store?Field.Store.YES:Field.Store.NO)); } } }
private void processSSDVFacetFields(Map<String,List<SortedSetDocValuesFacetField>> byField, Document doc) throws IOException { //System.out.println("process SSDV: " + byField); for(Map.Entry<String,List<SortedSetDocValuesFacetField>> ent : byField.entrySet()) { String indexFieldName = ent.getKey(); //System.out.println(" field=" + indexFieldName); for(SortedSetDocValuesFacetField facetField : ent.getValue()) { FacetLabel cp = new FacetLabel(facetField.dim, facetField.label); String fullPath = pathToString(cp.components, cp.length); //System.out.println("add " + fullPath); // For facet counts: doc.add(new SortedSetDocValuesField(indexFieldName, new BytesRef(fullPath))); // For drill-down: doc.add(new StringField(indexFieldName, fullPath, Field.Store.NO)); FacetsConfig.DimConfig ft = getDimConfig(facetField.dim); if (ft.requireDimensionDrillDown) { doc.add(new StringField(indexFieldName, facetField.dim, Field.Store.NO)); } } } }
@Test public void testSerializationOfSortedSetDocValuesField() throws Exception { Document document = new Document(); document.add( new SortedSetDocValuesField( "foo", new BytesRef( "hello" ) ) ); document.add( new SortedSetDocValuesField( "foo", new BytesRef( "world" ) ) ); List<LuceneWork> expectedWorkList = buildLuceneWorks( document ); serializeDeserializeAndAssert( expectedWorkList ); }
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 List<LuceneWork> buildV12Works() throws Exception { List<LuceneWork> works = new ArrayList<>(); Document document = new Document(); document.add( new NumericDocValuesField( "foo", 22L ) ); document.add( new BinaryDocValuesField( "foo", new BytesRef( "world" ) ) ); document.add( new SortedSetDocValuesField( "foo", new BytesRef( "hello" ) ) ); document.add( new SortedDocValuesField( "foo", new BytesRef( "world" ) ) ); works.add( new AddLuceneWork( 123, "123", remoteTypeId, document ) ); return works; }
@Override protected void parseCreateField(ParseContext context, List<IndexableField> fields) throws IOException { if (fieldType().indexOptions() == IndexOptions.NONE && !fieldType().stored()) { return; } fields.add(new Field(fieldType().name(), context.sourceToParse().type(), fieldType())); if (fieldType().hasDocValues()) { fields.add(new SortedSetDocValuesField(fieldType().name(), new BytesRef(context.sourceToParse().type()))); } }
@Test public void testSerializationOfMultipleDocValuesFields() throws Exception { Document document = new Document(); document.add( new NumericDocValuesField( "foo", 22L ) ); document.add( new BinaryDocValuesField( "foo", new BytesRef( "world" ) ) ); document.add( new SortedSetDocValuesField( "foo", new BytesRef( "hello" ) ) ); document.add( new SortedSetDocValuesField( "foo", new BytesRef( "world" ) ) ); document.add( new SortedDocValuesField( "foo", new BytesRef( "world" ) ) ); List<LuceneWork> expectedWorkList = buildLuceneWorks( document ); serializeDeserializeAndAssert( expectedWorkList ); }
@Override protected void parseCreateField(ParseContext context, List<IndexableField> fields) throws IOException { if (fieldType().indexOptions() == IndexOptions.NONE && !fieldType().stored()) { return; } fields.add(new Field(fieldType().name(), context.sourceToParse().type(), fieldType())); if (fieldType().hasDocValues()) { fields.add(new SortedSetDocValuesField(fieldType().name(), new BytesRef(context.sourceToParse().type()))); } }
@Override protected void parseCreateField(ParseContext context, List<IndexableField> fields) throws IOException { if (fieldType().indexOptions() == IndexOptions.NONE && !fieldType().stored()) { return; } fields.add(new Field(fieldType().name(), context.sourceToParse().type(), fieldType())); if (fieldType().hasDocValues()) { fields.add(new SortedSetDocValuesField(fieldType().name(), new BytesRef(context.sourceToParse().type()))); } }
@Override protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException { if (fieldType().indexOptions() == IndexOptions.NONE && !fieldType().stored()) { return; } fields.add(new Field(fieldType().names().indexName(), context.type(), fieldType())); if (fieldType().hasDocValues()) { fields.add(new SortedSetDocValuesField(fieldType().names().indexName(), new BytesRef(context.type()))); } }
@Override public void createField(ParseContext context, Object value) throws IOException { if (fieldType().indexOptions() == IndexOptions.NONE && !fieldType().stored()) { return; } context.doc().add(new Field(fieldType().name(), context.type(), fieldType())); if (fieldType().hasDocValues()) { context.doc().add(new SortedSetDocValuesField(fieldType().name(), new BytesRef(context.type()))); } }
@Override public void createField(ParseContext context, Object object) throws IOException { //ValueAndBoost valueAndBoost = new ValueAndBoost((String)object, fieldType().boost()); ValueAndBoost valueAndBoost = createFieldForString(context, fieldType().nullValueAsString(), fieldType().boost(), (String)object); if (valueAndBoost.value() == null) { return; } if (context.includeInAll(includeInAll, this)) { context.allEntries().addText(fieldType().name(), valueAndBoost.value(), valueAndBoost.boost()); } if (fieldType().indexOptions() != IndexOptions.NONE || fieldType().stored()) { Field field = new Field(fieldType().name(), valueAndBoost.value(), fieldType()); if (valueAndBoost.boost() != 1f && Version.indexCreated(context.indexSettings()).before(Version.V_5_0_0_alpha1)) { field.setBoost(valueAndBoost.boost()); } context.doc().add(field); } if (fieldType().hasDocValues()) { Field field = new SortedSetDocValuesField(fieldType().name(), new BytesRef(valueAndBoost.value())); context.doc().add(field); } super.createField(context, object); }