Package org.apache.lucene.index

Examples of org.apache.lucene.index.IndexableField


    //If we still didn't know the value using any bridge, return the raw value or string:
    for ( int index = 0; index < result.length; index++ ) {
      if ( result[index] == NOT_SET ) {
        result[index] = null; // make sure we never return NOT_SET
        if ( document != null ) {
          IndexableField field = document.getField( fields[index] );
          if ( field != null ) {
            result[index] = extractObjectFromFieldable( field );
          }
        }
      }
View Full Code Here


    //If we still didn't know the value using any bridge, return the raw value or string:
    for ( int index = 0; index < result.length; index++ ) {
      if ( result[index] == NOT_SET ) {
        result[index] = null; // make sure we never return NOT_SET
        if ( document != null ) {
          IndexableField field = document.getField( fields[index] );
          if ( field != null ) {
            result[index] = extractObjectFromFieldable( field );
          }
        }
      }
View Full Code Here

    Map<String, String[]> map = new HashMap<String, String[]>();
    if (doc != null) {
      List<IndexableField> fields = doc.getFields();
      Iterator<IndexableField> iter = fields.iterator();
      while (iter.hasNext()) {
        IndexableField fld = iter.next();
        String fieldname = fld.name();
        map.put(fieldname, doc.getValues(fieldname));
      }
    }
    return map;
  }
View Full Code Here

        Analyzer analyzer = context.docMapper().mappers().indexAnalyzer();
        if (path != null) {
            String value = null;
            List<IndexableField> fields = context.doc().getFields();
            for (int i = 0, fieldsSize = fields.size(); i < fieldsSize; i++) {
                IndexableField field = fields.get(i);
                if (field.name().equals(path)) {
                    value = field.stringValue();
                    break;
                }
            }
            if (value == null) {
                value = context.ignoredValue(path);
View Full Code Here

        if (context.sourceToParse().id() == null) {
            super.parse(context);
            // since we did not have the uid in the pre phase, we did not add it automatically to the nested docs
            // as they were created we need to make sure we add it to all the nested docs...
            if (context.docs().size() > 1) {
                final IndexableField uidField = context.rootDoc().getField(UidFieldMapper.NAME);
                assert uidField != null;
                // we need to go over the docs and add it...
                for (int i = 1; i < context.docs().size(); i++) {
                    final Document doc = context.docs().get(i);
                    doc.add(new Field(UidFieldMapper.NAME, uidField.stringValue(), Defaults.NESTED_FIELD_TYPE));
                }
            }
        }
    }
View Full Code Here

        if (nested.isNested()) {
            context = context.createNestedContext(fullPath);
            Document nestedDoc = context.doc();
            Document parentDoc = nestedDoc.getParent();
            // pre add the uid field if possible (id was already provided)
            IndexableField uidField = parentDoc.getField(UidFieldMapper.NAME);
            if (uidField != null) {
                // we don't need to add it as a full uid field in nested docs, since we don't need versioning
                // we also rely on this for UidField#loadVersion

                // this is a deeply nested field
                nestedDoc.add(new Field(UidFieldMapper.NAME, uidField.stringValue(), UidFieldMapper.Defaults.NESTED_FIELD_TYPE));
            }
            // the type of the nested doc starts with __, so we can identify that its a nested one in filters
            // note, we don't prefix it with the type of the doc since it allows us to execute a nested query
            // across types (for example, with similar nested objects)
            nestedDoc.add(new Field(TypeFieldMapper.NAME, nestedTypePathAsString, TypeFieldMapper.Defaults.FIELD_TYPE));
View Full Code Here

                        IndexableField[] latFields = doc.getFields(mapping.fieldName + ".lat");
                        if (lonFields.length > 0 && latFields.length > 0) {
                            geohashes = new ArrayList<>(fields.length);
                            GeoPoint spare = new GeoPoint();
                            for (int i = 0 ; i < lonFields.length ; i++) {
                                IndexableField lonField = lonFields[i];
                                IndexableField latField = latFields[i];
                                assert lonField.fieldType().docValueType() == latField.fieldType().docValueType();
                                // we write doc values fields differently: one field for all values, so we need to only care about indexed fields
                                if (lonField.fieldType().docValueType() == DocValuesType.NONE) {
                                    spare.reset(latField.numericValue().doubleValue(), lonField.numericValue().doubleValue());
                                    geohashes.add(spare.geohash());
                                }
                            }
                        } else {
                            geohashes = mapping.defaultLocations;
View Full Code Here

                .startObject("long_field").field("boost", 8.0).field("value", 50).endObject()
                .startObject("short_field").field("boost", 9.0).field("value", 60).endObject()
                .bytes();
        Document doc = docMapper.parse(json).rootDoc();

        IndexableField f = doc.getField("str_field");
        assertThat((double) f.boost(), closeTo(2.0, 0.001));

        f = doc.getField("int_field");
        assertThat((double) f.boost(), closeTo(3.0, 0.001));

        f = doc.getField("byte_field");
        assertThat((double) f.boost(), closeTo(4.0, 0.001));

        f = doc.getField("date_field");
        assertThat((double) f.boost(), closeTo(5.0, 0.001));

        f = doc.getField("double_field");
        assertThat((double) f.boost(), closeTo(6.0, 0.001));

        f = doc.getField("float_field");
        assertThat((double) f.boost(), closeTo(7.0, 0.001));

        f = doc.getField("long_field");
        assertThat((double) f.boost(), closeTo(8.0, 0.001));

        f = doc.getField("short_field");
        assertThat((double) f.boost(), closeTo(9.0, 0.001));
    }
View Full Code Here

        String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/simple/test-mapping.json");
        DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse(mapping);
        byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/simple/test-data.json");
        Document doc = docMapper.parse(new BytesArray(json)).rootDoc();

        IndexableField f = doc.getField("name");
        assertThat(f.name(), equalTo("name"));
        assertThat(f.stringValue(), equalTo("some name"));
        assertNotSame(IndexOptions.NONE, f.fieldType().indexOptions());
        assertThat(f.fieldType().tokenized(), equalTo(false));

        FieldMappers fieldMappers = docMapper.mappers().fullName("name");
        assertThat(fieldMappers.mappers().size(), equalTo(1));

        f = doc.getField("multi1");
        assertThat(f.name(), equalTo("multi1"));
        assertThat(f.stringValue(), equalTo("multi 1"));
        assertNotSame(IndexOptions.NONE, f.fieldType().indexOptions());
        assertThat(f.fieldType().tokenized(), equalTo(true));

        fieldMappers = docMapper.mappers().fullName("multi1");
        assertThat(fieldMappers.mappers().size(), equalTo(1));

        f = doc.getField("multi1.org");
        assertThat(f.name(), equalTo("multi1.org"));
        assertThat(f.stringValue(), equalTo("multi 1"));
        assertNotSame(IndexOptions.NONE, f.fieldType().indexOptions());
        assertThat(f.fieldType().tokenized(), equalTo(false));

        fieldMappers = docMapper.mappers().fullName("multi1.org");
        assertThat(fieldMappers.mappers().size(), equalTo(1));

        f = doc.getField("multi2");
        assertThat(f.name(), equalTo("multi2"));
        assertThat(f.stringValue(), equalTo("multi 2"));
        assertNotSame(IndexOptions.NONE, f.fieldType().indexOptions());
        assertThat(f.fieldType().tokenized(), equalTo(true));

        fieldMappers = docMapper.mappers().fullName("multi2");
        assertThat(fieldMappers.mappers().size(), equalTo(1));

        f = doc.getField("multi2.org");
        assertThat(f.name(), equalTo("multi2.org"));
        assertThat(f.stringValue(), equalTo("multi 2"));
        assertNotSame(IndexOptions.NONE, f.fieldType().indexOptions());
        assertThat(f.fieldType().tokenized(), equalTo(false));

        fieldMappers = docMapper.mappers().fullName("multi2.org");
        assertThat(fieldMappers.mappers().size(), equalTo(1));
    }
View Full Code Here

        docMapper = parser.parse(docMapper.mappingSource().string());

        byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/simple/test-data.json");
        Document doc = docMapper.parse(new BytesArray(json)).rootDoc();

        IndexableField f = doc.getField("name");
        assertThat(f.name(), equalTo("name"));
        assertThat(f.stringValue(), equalTo("some name"));
        assertNotSame(IndexOptions.NONE, f.fieldType().indexOptions());
        assertThat(f.fieldType().tokenized(), equalTo(false));

        FieldMappers fieldMappers = docMapper.mappers().fullName("name");
        assertThat(fieldMappers.mappers().size(), equalTo(1));

        f = doc.getField("multi1");
        assertThat(f.name(), equalTo("multi1"));
        assertThat(f.stringValue(), equalTo("multi 1"));
        assertNotSame(IndexOptions.NONE, f.fieldType().indexOptions());
        assertThat(f.fieldType().tokenized(), equalTo(true));

        fieldMappers = docMapper.mappers().fullName("multi1");
        assertThat(fieldMappers.mappers().size(), equalTo(1));

        f = doc.getField("multi1.org");
        assertThat(f.name(), equalTo("multi1.org"));
        assertThat(f.stringValue(), equalTo("multi 1"));
        assertNotSame(IndexOptions.NONE, f.fieldType().indexOptions());
        assertThat(f.fieldType().tokenized(), equalTo(false));

        fieldMappers = docMapper.mappers().fullName("multi1.org");
        assertThat(fieldMappers.mappers().size(), equalTo(1));

        f = doc.getField("multi2");
        assertThat(f.name(), equalTo("multi2"));
        assertThat(f.stringValue(), equalTo("multi 2"));
        assertNotSame(IndexOptions.NONE, f.fieldType().indexOptions());
        assertThat(f.fieldType().tokenized(), equalTo(true));

        fieldMappers = docMapper.mappers().fullName("multi2");
        assertThat(fieldMappers.mappers().size(), equalTo(1));

        f = doc.getField("multi2.org");
        assertThat(f.name(), equalTo("multi2.org"));
        assertThat(f.stringValue(), equalTo("multi 2"));
        assertNotSame(IndexOptions.NONE, f.fieldType().indexOptions());
        assertThat(f.fieldType().tokenized(), equalTo(false));

        fieldMappers = docMapper.mappers().fullName("multi2.org");
        assertThat(fieldMappers.mappers().size(), equalTo(1));
    }
View Full Code Here

TOP

Related Classes of org.apache.lucene.index.IndexableField

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.