List<String> getIndexSettingsValidationErrors(Settings settings) {
   String customPath = IndexMetaData.INDEX_DATA_PATH_SETTING.get(settings);
   List<String> validationErrors = new ArrayList<>();
   if (Strings.isEmpty(customPath) == false && env.sharedDataFile() == null) {
     validationErrors.add("path.shared_data must be set in order to use custom data paths");
   } else if (Strings.isEmpty(customPath) == false) {
     Path resolvedPath = PathUtils.get(new Path[] {env.sharedDataFile()}, customPath);
     if (resolvedPath == null) {
       validationErrors.add(
           "custom path ["
               + customPath
               + "] is not a sub-path of path.shared_data ["
               + env.sharedDataFile()
               + "]");
     }
   }
   // norelease - this can be removed?
   Integer number_of_primaries = settings.getAsInt(IndexMetaData.SETTING_NUMBER_OF_SHARDS, null);
   Integer number_of_replicas = settings.getAsInt(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, null);
   if (number_of_primaries != null && number_of_primaries <= 0) {
     validationErrors.add("index must have 1 or more primary shards");
   }
   if (number_of_replicas != null && number_of_replicas < 0) {
     validationErrors.add("index must have 0 or more replica shards");
   }
   return validationErrors;
 }
 public Builder(String field, String geohash, boolean neighbors) {
   if (Strings.isEmpty(field)) {
     throw new IllegalArgumentException("fieldName must not be null");
   }
   if (Strings.isEmpty(geohash)) {
     throw new IllegalArgumentException("geohash or point must be defined");
   }
   this.fieldName = field;
   this.geohash = geohash;
   this.neighbors = neighbors;
 }
 /** Add a field to run the query against with a specific boost. */
 public SimpleQueryStringBuilder field(String field, float boost) {
   if (Strings.isEmpty(field)) {
     throw new IllegalArgumentException("supplied field is null or empty.");
   }
   this.fieldsAndWeights.put(field, boost);
   return this;
 }
 /** Add a field to run the query against. */
 public SimpleQueryStringBuilder field(String field) {
   if (Strings.isEmpty(field)) {
     throw new IllegalArgumentException("supplied field is null or empty.");
   }
   this.fieldsAndWeights.put(field, AbstractQueryBuilder.DEFAULT_BOOST);
   return this;
 }
 /**
  * Constructs a new {@link FieldMaskingSpanQueryBuilder} given an inner {@link SpanQueryBuilder}
  * for a given field
  *
  * @param queryBuilder inner {@link SpanQueryBuilder}
  * @param fieldName the field name
  */
 public FieldMaskingSpanQueryBuilder(SpanQueryBuilder queryBuilder, String fieldName) {
   if (Strings.isEmpty(fieldName)) {
     throw new IllegalArgumentException("field name is null or empty");
   }
   if (queryBuilder == null) {
     throw new IllegalArgumentException("inner clause [query] cannot be null.");
   }
   this.queryBuilder = queryBuilder;
   this.fieldName = fieldName;
 }
 /** Constructs a new common terms query. */
 public CommonTermsQueryBuilder(String fieldName, Object text) {
   if (Strings.isEmpty(fieldName)) {
     throw new IllegalArgumentException("field name is null or empty");
   }
   if (text == null) {
     throw new IllegalArgumentException("text cannot be null.");
   }
   this.fieldName = fieldName;
   this.text = text;
 }
 /**
  * Constructs a new base term query. In case value is assigned to a string, we internally convert
  * it to a {@link BytesRef} because in {@link TermQueryParser} and {@link SpanTermQueryParser}
  * string values are parsed to {@link BytesRef} and we want internal representation of query to be
  * equal regardless of whether it was created from XContent or via Java API.
  *
  * @param fieldName The name of the field
  * @param value The value of the term
  */
 public BaseTermQueryBuilder(String fieldName, Object value) {
   if (Strings.isEmpty(fieldName)) {
     throw new IllegalArgumentException("field name is null or empty");
   }
   if (value == null) {
     throw new IllegalArgumentException("value cannot be null");
   }
   this.fieldName = fieldName;
   this.value = convertToBytesRefIfString(value);
 }
 public IndexService newIndexService(
     NodeEnvironment environment,
     IndexService.ShardStoreDeleter shardStoreDeleter,
     NodeServicesProvider servicesProvider,
     MapperRegistry mapperRegistry,
     IndexingOperationListener... listeners)
     throws IOException {
   IndexSearcherWrapperFactory searcherWrapperFactory =
       indexSearcherWrapper.get() == null ? (shard) -> null : indexSearcherWrapper.get();
   IndexEventListener eventListener = freeze();
   final String storeType = indexSettings.getValue(INDEX_STORE_TYPE_SETTING);
   final IndexStore store;
   if (Strings.isEmpty(storeType) || isBuiltinType(storeType)) {
     store = new IndexStore(indexSettings, indexStoreConfig);
   } else {
     BiFunction<IndexSettings, IndexStoreConfig, IndexStore> factory = storeTypes.get(storeType);
     if (factory == null) {
       throw new IllegalArgumentException("Unknown store type [" + storeType + "]");
     }
     store = factory.apply(indexSettings, indexStoreConfig);
     if (store == null) {
       throw new IllegalStateException("store must not be null");
     }
   }
   indexSettings
       .getScopedSettings()
       .addSettingsUpdateConsumer(
           IndexStore.INDEX_STORE_THROTTLE_MAX_BYTES_PER_SEC_SETTING, store::setMaxRate);
   indexSettings
       .getScopedSettings()
       .addSettingsUpdateConsumer(IndexStore.INDEX_STORE_THROTTLE_TYPE_SETTING, store::setType);
   final String queryCacheType = indexSettings.getValue(INDEX_QUERY_CACHE_TYPE_SETTING);
   final BiFunction<IndexSettings, IndicesQueryCache, QueryCache> queryCacheProvider =
       queryCaches.get(queryCacheType);
   final QueryCache queryCache =
       queryCacheProvider.apply(indexSettings, servicesProvider.getIndicesQueryCache());
   return new IndexService(
       indexSettings,
       environment,
       new SimilarityService(indexSettings, similarities),
       shardStoreDeleter,
       analysisRegistry,
       engineFactory.get(),
       servicesProvider,
       queryCache,
       store,
       eventListener,
       searcherWrapperFactory,
       mapperRegistry,
       listeners);
 }
Ejemplo n.º 9
0
 /** Creates a query builder given a query provided as a string */
 public WrapperQueryBuilder(String source) {
   if (Strings.isEmpty(source)) {
     throw new IllegalArgumentException("query source string cannot be null or empty");
   }
   this.source = source.getBytes(StandardCharsets.UTF_8);
 }