Is Define Mapping is correct?


(Sam-4) #1

Hi

I have used using following java to generate following mapping :

        XContentBuilder indexSettings = null;
        XContentBuilder stopwordfilter = null;

             stopwordfilter=XContentFactory.jsonBuilder();
             stopwordfilter.startObject()
                        .startObject("stopwordfilter")
                        .field("type","stop")
                        .field("stopwords_path","D:\

\RabbitmqRiverExample\RabbitmqRiverExample\resources
\stopwords_eng.txt")
.field("ignore_case","true")
.endObject();
System.out.println(stopwordfilter.string());

            indexSettings = XContentFactory.jsonBuilder();
            indexSettings.startObject()
                    .startObject("index")
                    .startObject("analysis")
                    .startObject("analyzer")
                    .startObject("default")
                    .field("type","custom")
                    .field("tokenizer", "whitespace")
                    .field("filter", new String[]

{"asciifolding","lowercase","stopwordfilter"})
.field("filter",stopwordfilter)
.endObject().endObject().endObject().endObject().endObject();

            System.out.println(indexSettings.string());

            UpdateSettingsRequestBuilder settingsRequest

=client.admin().indices().prepareUpdateSettings();
settingsRequest.setSettings(indexSettings.string());
UpdateSettingsResponse settingsResponse
=settingsRequest.execute().actionGet();
System.out.println(settingsResponse);

Here i am define custom analyzer.please correct me if mapping is
wrong.

Thanks


(system) #2