Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="indexName">The name of the field that will be stored in the index. Defaults to the property/field name</param>
        /// <param name="store">Set to yes the store actual field in the index, no to not store it. Defaults to no (note, the JSON document itself is stored, and it can be retrieved from it).
        /// </param>
        /// <param name="index">Set to analyzed for the field to be indexed and searchable after being broken down into token using an analyzer. not_analyzed means that its still searchable, but does not go through any analysis process or broken down into tokens. no means that it won’t be searchable at all. Defaults to analyzed.</param>
        /// <param name="termVector">Possible values are no, yes, with_offsets, with_positions, with_positions_offsets. Defaults to no.</param>
        /// <param name="boost">The boost value. Defaults to 1.0.</param>
        /// <param name="nullValue">When there is a (JSON) null value for the field, use the null_value as the field value. Defaults to not adding the field at all.</param>
        /// <param name="omitNorms">Boolean value if norms should be omitted or not. Defaults to false.</param>
        /// <param name="omitTermFreqAndPositions">Boolean value if term freq and positions should be omitted. Defaults to false.</param>
        /// <param name="analyzer">The analyzer used to analyze the text contents when analyzed during indexing and when searching using a query string. Defaults to the globally configured analyzer.</param>
        /// <param name="indexAnalyzer">The analyzer used to analyze the text contents when analyzed during indexing.</param>
        /// <param name="searchAnalyzer">The analyzer used to analyze the field when part of a query string.</param>
        /// <param name="includeInAll">Should the field be included in the _all field (if enabled). Defaults to true or to the parent object type setting.</param>
        public StringFieldSetting AddStringField(string name, string indexName = null, Store store           = Store.no, IndexType index = IndexType.analyzed,
                                                 TermVector termVector         = TermVector.no, double boost = 1.0, string nullValue     = null,
                                                 bool omitNorms       = false, bool omitTermFreqAndPositions = false, string analyzer    = null,
                                                 string indexAnalyzer = null, string searchAnalyzer          = null, bool includeInAll   = true)
        {
            Contract.Assert(_fieldSettings != null);

            var field = new StringFieldSetting();

            field.Name       = name;
            field.IndexName  = indexName;
            field.Store      = store;
            field.Index      = index;
            field.TermVector = termVector;
            field.Boost      = boost;
            field.NullValue  = nullValue;
            field.OmitNorms  = omitNorms;
            field.OmitTermFreqAndPositions = omitTermFreqAndPositions;
            field.Analyzer       = analyzer;
            field.IndexAnalyzer  = indexAnalyzer;
            field.SearchAnalyzer = searchAnalyzer;
            field.IncludeInAll   = includeInAll;

            _fieldSettings[name] = field;
            return(field);
        }
        public void TestCreatingMapping()
        {
            var index = "index_operate" + Guid.NewGuid();
            var stringFieldSetting = new StringFieldSetting { Analyzer = "standard", Type = "string", NullValue = "mystr" };

            var typeSetting = new TypeSetting("custom_type");
            typeSetting.AddFieldSetting("medcl", stringFieldSetting);

            var typeSetting2 = new TypeSetting("hell_type1");
            var numfield = new NumberFieldSetting { Store = Store.yes, NullValue = 0.00 };
            typeSetting2.AddFieldSetting("name", numfield);

            client.CreateIndex(index);
            var result = client.PutMapping(index, typeSetting);
            Assert.AreEqual(true, result.Success);

            result = client.PutMapping(index, typeSetting2);
            Assert.AreEqual(true, result.Success);

            var result2 = client.DeleteIndex(index);
            Assert.AreEqual(true, result2.Success);
        }
		/// <summary>
		/// 
		/// </summary>
		/// <param name="indexName">The name of the field that will be stored in the index. Defaults to the property/field name</param>
		/// <param name="store">Set to yes the store actual field in the index, no to not store it. Defaults to no (note, the JSON document itself is stored, and it can be retrieved from it).
		/// </param>
		/// <param name="index">Set to analyzed for the field to be indexed and searchable after being broken down into token using an analyzer. not_analyzed means that its still searchable, but does not go through any analysis process or broken down into tokens. no means that it won’t be searchable at all. Defaults to analyzed.</param>
		/// <param name="termVector">Possible values are no, yes, with_offsets, with_positions, with_positions_offsets. Defaults to no.</param>
		/// <param name="boost">The boost value. Defaults to 1.0.</param>
		/// <param name="nullValue">When there is a (JSON) null value for the field, use the null_value as the field value. Defaults to not adding the field at all.</param>
		/// <param name="omitNorms">Boolean value if norms should be omitted or not. Defaults to false.</param>
		/// <param name="omitTermFreqAndPositions">Boolean value if term freq and positions should be omitted. Defaults to false.</param>
		/// <param name="analyzer">The analyzer used to analyze the text contents when analyzed during indexing and when searching using a query string. Defaults to the globally configured analyzer.</param>
		/// <param name="indexAnalyzer">The analyzer used to analyze the text contents when analyzed during indexing.</param>
		/// <param name="searchAnalyzer">The analyzer used to analyze the field when part of a query string.</param>
		/// <param name="includeInAll">Should the field be included in the _all field (if enabled). Defaults to true or to the parent object type setting.</param>
        public StringFieldSetting AddStringField(string name, string indexName = null, Store store = Store.no, IndexType index = IndexType.analyzed,
									  TermVector termVector = TermVector.no, double boost = 1.0, string nullValue = null,
									  bool omitNorms = false, bool omitTermFreqAndPositions = false, string analyzer = null,
									  string indexAnalyzer = null, string searchAnalyzer = null, bool includeInAll = true)
		{
			Contract.Assert(_fieldSettings != null);

			var field = new StringFieldSetting();
			field.Name = name;
			field.IndexName = indexName;
			field.Store = store;
			field.Index = index;
			field.TermVector = termVector;
			field.Boost = boost;
			field.NullValue = nullValue;
			field.OmitNorms = omitNorms;
			field.OmitTermFreqAndPositions = omitTermFreqAndPositions;
			field.Analyzer = analyzer;
			field.IndexAnalyzer = indexAnalyzer;
			field.SearchAnalyzer = searchAnalyzer;
			field.IncludeInAll = includeInAll;

			_fieldSettings[name] = field;
		    return field;
		}