Package org.elasticsearch.index.analysis

Examples of org.elasticsearch.index.analysis.FieldNameAnalyzer


        this.fieldMappers = ImmutableList.copyOf(fieldMappers);
        this.nameFieldMappers = ImmutableMap.copyOf(tempNameFieldMappers);
        this.indexNameFieldMappers = ImmutableMap.copyOf(tempIndexNameFieldMappers);
        this.fullNameFieldMappers = ImmutableMap.copyOf(tempFullNameFieldMappers);

        this.indexAnalyzer = new FieldNameAnalyzer(indexAnalyzers, docMapper.indexAnalyzer());
        this.searchAnalyzer = new FieldNameAnalyzer(searchAnalyzers, docMapper.searchAnalyzer());
    }
View Full Code Here


    /**
     * A smart analyzer used for indexing that takes into account specific analyzers configured
     * per {@link FieldMapper} with a custom default analyzer for no explicit field analyzer.
     */
    public Analyzer indexAnalyzer(Analyzer defaultAnalyzer) {
        return new FieldNameAnalyzer(indexAnalyzer.analyzers(), defaultAnalyzer);
    }
View Full Code Here

                .field("field_analyzer", "whitespace")
                .field("field1", "value1")
                .field("field2", "value2")
                .endObject().copiedBytes());

        FieldNameAnalyzer analyzer = (FieldNameAnalyzer) doc.analyzer();
        assertThat(((NamedAnalyzer) analyzer.defaultAnalyzer()).name(), equalTo("whitespace"));
        assertThat(((NamedAnalyzer) analyzer.analyzers().get("field1")), nullValue());
        assertThat(((NamedAnalyzer) analyzer.analyzers().get("field2")).name(), equalTo("simple"));

        // check that it serializes and de-serializes correctly

        DocumentMapper reparsedMapper = MapperTests.newParser().parse(documentMapper.mappingSource().string());

        doc = reparsedMapper.parse("type", "1", XContentFactory.jsonBuilder().startObject()
                .field("field_analyzer", "whitespace")
                .field("field1", "value1")
                .field("field2", "value2")
                .endObject().copiedBytes());

        analyzer = (FieldNameAnalyzer) doc.analyzer();
        assertThat(((NamedAnalyzer) analyzer.defaultAnalyzer()).name(), equalTo("whitespace"));
        assertThat(((NamedAnalyzer) analyzer.analyzers().get("field1")), nullValue());
        assertThat(((NamedAnalyzer) analyzer.analyzers().get("field2")).name(), equalTo("simple"));
    }
View Full Code Here

                .field("field_analyzer", "whitespace")
                .field("field1", "value1")
                .field("field2", "value2")
                .endObject().copiedBytes());

        FieldNameAnalyzer analyzer = (FieldNameAnalyzer) doc.analyzer();
        assertThat(((NamedAnalyzer) analyzer.defaultAnalyzer()).name(), equalTo("whitespace"));
        assertThat(((NamedAnalyzer) analyzer.analyzers().get("field1")), nullValue());
        assertThat(((NamedAnalyzer) analyzer.analyzers().get("field2")).name(), equalTo("simple"));

        // check that it serializes and de-serializes correctly

        DocumentMapper reparsedMapper = MapperTests.newParser().parse(documentMapper.mappingSource().string());

        doc = reparsedMapper.parse("type", "1", XContentFactory.jsonBuilder().startObject()
                .field("field_analyzer", "whitespace")
                .field("field1", "value1")
                .field("field2", "value2")
                .endObject().copiedBytes());

        analyzer = (FieldNameAnalyzer) doc.analyzer();
        assertThat(((NamedAnalyzer) analyzer.defaultAnalyzer()).name(), equalTo("whitespace"));
        assertThat(((NamedAnalyzer) analyzer.analyzers().get("field1")), nullValue());
        assertThat(((NamedAnalyzer) analyzer.analyzers().get("field2")).name(), equalTo("simple"));
    }
View Full Code Here

                .field("field_analyzer", "whitespace")
                .field("field1", "value1")
                .field("field2", "value2")
                .endObject().copiedBytes());

        FieldNameAnalyzer analyzer = (FieldNameAnalyzer) doc.analyzer();
        assertThat(((NamedAnalyzer) analyzer.defaultAnalyzer()).name(), equalTo("whitespace"));
        assertThat(((NamedAnalyzer) analyzer.analyzers().get("field1")), nullValue());
        assertThat(((NamedAnalyzer) analyzer.analyzers().get("field2")).name(), equalTo("simple"));

        // check that it serializes and de-serializes correctly

        DocumentMapper reparsedMapper = MapperTests.newParser().parse(documentMapper.mappingSource().string());

        doc = reparsedMapper.parse("type", "1", XContentFactory.jsonBuilder().startObject()
                .field("field_analyzer", "whitespace")
                .field("field1", "value1")
                .field("field2", "value2")
                .endObject().copiedBytes());

        analyzer = (FieldNameAnalyzer) doc.analyzer();
        assertThat(((NamedAnalyzer) analyzer.defaultAnalyzer()).name(), equalTo("whitespace"));
        assertThat(((NamedAnalyzer) analyzer.analyzers().get("field1")), nullValue());
        assertThat(((NamedAnalyzer) analyzer.analyzers().get("field2")).name(), equalTo("simple"));
    }
View Full Code Here

    private final FieldNameAnalyzer indexAnalyzer;
    private final FieldNameAnalyzer searchAnalyzer;
    private final FieldNameAnalyzer searchQuoteAnalyzer;

    public DocumentFieldMappers(DocumentMapper docMapper) {
        this(new FieldMappersLookup(), new FieldNameAnalyzer(docMapper.indexAnalyzer()), new FieldNameAnalyzer(docMapper.searchAnalyzer()), new FieldNameAnalyzer(docMapper.searchQuotedAnalyzer()));
    }
View Full Code Here

        this.searchQuoteAnalyzer = searchQuoteAnalyzer;
    }

    public DocumentFieldMappers copyAndAllAll(Collection<? extends FieldMapper<?>> newMappers) {
        FieldMappersLookup fieldMappers = this.fieldMappers.copyAndAddAll(newMappers);
        FieldNameAnalyzer indexAnalyzer = this.indexAnalyzer.copyAndAddAll(Collections2.transform(newMappers, new Function<FieldMapper<?>, Map.Entry<String, Analyzer>>() {
            @Override
            public Map.Entry<String, Analyzer> apply(FieldMapper<?> input) {
                return Maps.immutableEntry(input.names().indexName(), input.indexAnalyzer());
            }
        }));
        FieldNameAnalyzer searchAnalyzer = this.searchAnalyzer.copyAndAddAll(Collections2.transform(newMappers, new Function<FieldMapper<?>, Map.Entry<String, Analyzer>>() {
            @Override
            public Map.Entry<String, Analyzer> apply(FieldMapper<?> input) {
                return Maps.immutableEntry(input.names().indexName(), input.searchAnalyzer());
            }
        }));
        FieldNameAnalyzer searchQuoteAnalyzer = this.searchQuoteAnalyzer.copyAndAddAll(Collections2.transform(newMappers, new Function<FieldMapper<?>, Map.Entry<String, Analyzer>>() {
            @Override
            public Map.Entry<String, Analyzer> apply(FieldMapper<?> input) {
                return Maps.immutableEntry(input.names().indexName(), input.searchQuoteAnalyzer());
            }
        }));
View Full Code Here

    /**
     * A smart analyzer used for indexing that takes into account specific analyzers configured
     * per {@link FieldMapper} with a custom default analyzer for no explicit field analyzer.
     */
    public Analyzer indexAnalyzer(Analyzer defaultAnalyzer) {
        return new FieldNameAnalyzer(indexAnalyzer.analyzers(), defaultAnalyzer);
    }
View Full Code Here

                .field("field_analyzer", "whitespace")
                .field("field1", "value1")
                .field("field2", "value2")
                .endObject().bytes());

        FieldNameAnalyzer analyzer = (FieldNameAnalyzer) doc.analyzer();
        assertThat(((NamedAnalyzer) analyzer.defaultAnalyzer()).name(), equalTo("whitespace"));
        assertThat(((NamedAnalyzer) analyzer.analyzers().get("field1")), nullValue());
        assertThat(((NamedAnalyzer) analyzer.analyzers().get("field2")).name(), equalTo("simple"));

        // check that it serializes and de-serializes correctly

        DocumentMapper reparsedMapper = parser.parse(documentMapper.mappingSource().string());

        doc = reparsedMapper.parse("type", "1", XContentFactory.jsonBuilder().startObject()
                .field("field_analyzer", "whitespace")
                .field("field1", "value1")
                .field("field2", "value2")
                .endObject().bytes());

        analyzer = (FieldNameAnalyzer) doc.analyzer();
        assertThat(((NamedAnalyzer) analyzer.defaultAnalyzer()).name(), equalTo("whitespace"));
        assertThat(((NamedAnalyzer) analyzer.analyzers().get("field1")), nullValue());
        assertThat(((NamedAnalyzer) analyzer.analyzers().get("field2")).name(), equalTo("simple"));
    }
View Full Code Here

                .field("field_analyzer", "whitespace")
                .field("field1", "value1")
                .field("field2", "value2")
                .endObject().bytes());

        FieldNameAnalyzer analyzer = (FieldNameAnalyzer) doc.analyzer();
        assertThat(((NamedAnalyzer) analyzer.defaultAnalyzer()).name(), equalTo("whitespace"));
        assertThat(((NamedAnalyzer) analyzer.analyzers().get("field1")), nullValue());
        assertThat(((NamedAnalyzer) analyzer.analyzers().get("field2")).name(), equalTo("simple"));

        // check that it serializes and de-serializes correctly

        DocumentMapper reparsedMapper = parser.parse(documentMapper.mappingSource().string());

        doc = reparsedMapper.parse("type", "1", XContentFactory.jsonBuilder().startObject()
                .field("field_analyzer", "whitespace")
                .field("field1", "value1")
                .field("field2", "value2")
                .endObject().bytes());

        analyzer = (FieldNameAnalyzer) doc.analyzer();
        assertThat(((NamedAnalyzer) analyzer.defaultAnalyzer()).name(), equalTo("whitespace"));
        assertThat(((NamedAnalyzer) analyzer.analyzers().get("field1")), nullValue());
        assertThat(((NamedAnalyzer) analyzer.analyzers().get("field2")).name(), equalTo("simple"));
    }
View Full Code Here

TOP

Related Classes of org.elasticsearch.index.analysis.FieldNameAnalyzer

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.