FieldType: Remove unnecessary KEYWORD type
Elasticsearch 5 split string type in two: keyword (also known as exact in gerrit index type system) and text (also known as full text in gerrit index type system). During migration from Elasticsearch 2 to 5 exact type was erroneously split in exact and keyword types, that are the same. This reverts commit506125e71a
. This reverts commit09fdc3eaad
. Change-Id: I788e4d06d490687508c4bfd1703037a268fe31a5
This commit is contained in:
parent
852e5ac7ac
commit
0f6c9bd34c
@ -28,8 +28,6 @@ class ElasticMapping {
|
|||||||
FieldType<?> fieldType = field.getType();
|
FieldType<?> fieldType = field.getType();
|
||||||
if (fieldType == FieldType.EXACT) {
|
if (fieldType == FieldType.EXACT) {
|
||||||
mapping.addExactField(name);
|
mapping.addExactField(name);
|
||||||
} else if (fieldType == FieldType.KEYWORD) {
|
|
||||||
mapping.addKeywordField(name);
|
|
||||||
} else if (fieldType == FieldType.TIMESTAMP) {
|
} else if (fieldType == FieldType.TIMESTAMP) {
|
||||||
mapping.addTimestamp(name);
|
mapping.addTimestamp(name);
|
||||||
} else if (fieldType == FieldType.INTEGER
|
} else if (fieldType == FieldType.INTEGER
|
||||||
@ -63,20 +61,10 @@ class ElasticMapping {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Builder addExactField(String name) {
|
Builder addExactField(String name) {
|
||||||
FieldProperties key = new FieldProperties(adapter.keywordFieldType());
|
FieldProperties key = new FieldProperties(adapter.exactFieldType());
|
||||||
key.index = adapter.indexProperty();
|
key.index = adapter.indexProperty();
|
||||||
FieldProperties properties;
|
FieldProperties properties;
|
||||||
properties = new FieldProperties(adapter.stringFieldType());
|
properties = new FieldProperties(adapter.exactFieldType());
|
||||||
properties.fields = ImmutableMap.of("key", key);
|
|
||||||
fields.put(name, properties);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
Builder addKeywordField(String name) {
|
|
||||||
FieldProperties key = new FieldProperties(adapter.keywordFieldType());
|
|
||||||
key.index = adapter.indexProperty();
|
|
||||||
FieldProperties properties;
|
|
||||||
properties = new FieldProperties(adapter.keywordFieldType());
|
|
||||||
properties.fields = ImmutableMap.of("key", key);
|
properties.fields = ImmutableMap.of("key", key);
|
||||||
fields.put(name, properties);
|
fields.put(name, properties);
|
||||||
return this;
|
return this;
|
||||||
|
@ -20,7 +20,7 @@ public class ElasticQueryAdapter {
|
|||||||
private final boolean ignoreUnmapped;
|
private final boolean ignoreUnmapped;
|
||||||
private final String searchFilteringName;
|
private final String searchFilteringName;
|
||||||
private final String indicesExistParam;
|
private final String indicesExistParam;
|
||||||
private final String keywordFieldType;
|
private final String exactFieldType;
|
||||||
private final String stringFieldType;
|
private final String stringFieldType;
|
||||||
private final String indexProperty;
|
private final String indexProperty;
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ public class ElasticQueryAdapter {
|
|||||||
case V6_2:
|
case V6_2:
|
||||||
this.searchFilteringName = "_source";
|
this.searchFilteringName = "_source";
|
||||||
this.indicesExistParam = "?allow_no_indices=false";
|
this.indicesExistParam = "?allow_no_indices=false";
|
||||||
this.keywordFieldType = "keyword";
|
this.exactFieldType = "keyword";
|
||||||
this.stringFieldType = "text";
|
this.stringFieldType = "text";
|
||||||
this.indexProperty = "true";
|
this.indexProperty = "true";
|
||||||
break;
|
break;
|
||||||
@ -39,7 +39,7 @@ public class ElasticQueryAdapter {
|
|||||||
default:
|
default:
|
||||||
this.searchFilteringName = "fields";
|
this.searchFilteringName = "fields";
|
||||||
this.indicesExistParam = "";
|
this.indicesExistParam = "";
|
||||||
this.keywordFieldType = "string";
|
this.exactFieldType = "string";
|
||||||
this.stringFieldType = "string";
|
this.stringFieldType = "string";
|
||||||
this.indexProperty = "not_analyzed";
|
this.indexProperty = "not_analyzed";
|
||||||
break;
|
break;
|
||||||
@ -60,8 +60,8 @@ public class ElasticQueryAdapter {
|
|||||||
return indicesExistParam;
|
return indicesExistParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
String keywordFieldType() {
|
String exactFieldType() {
|
||||||
return keywordFieldType;
|
return exactFieldType;
|
||||||
}
|
}
|
||||||
|
|
||||||
String stringFieldType() {
|
String stringFieldType() {
|
||||||
|
@ -94,7 +94,7 @@ public class ElasticQueryBuilder {
|
|||||||
return intRangeQuery(p);
|
return intRangeQuery(p);
|
||||||
} else if (type == FieldType.TIMESTAMP) {
|
} else if (type == FieldType.TIMESTAMP) {
|
||||||
return timestampQuery(p);
|
return timestampQuery(p);
|
||||||
} else if (type == FieldType.EXACT || type == FieldType.KEYWORD) {
|
} else if (type == FieldType.EXACT) {
|
||||||
return exactQuery(p);
|
return exactQuery(p);
|
||||||
} else if (type == FieldType.PREFIX) {
|
} else if (type == FieldType.PREFIX) {
|
||||||
return QueryBuilders.matchPhrasePrefixQuery(name, value);
|
return QueryBuilders.matchPhrasePrefixQuery(name, value);
|
||||||
|
@ -337,7 +337,7 @@ public abstract class AbstractLuceneIndex<K, V> implements Index<K, V> {
|
|||||||
for (Object value : values.getValues()) {
|
for (Object value : values.getValues()) {
|
||||||
doc.add(new LongField(name, ((Timestamp) value).getTime(), store));
|
doc.add(new LongField(name, ((Timestamp) value).getTime(), store));
|
||||||
}
|
}
|
||||||
} else if (type == FieldType.KEYWORD || type == FieldType.EXACT || type == FieldType.PREFIX) {
|
} else if (type == FieldType.EXACT || type == FieldType.PREFIX) {
|
||||||
for (Object value : values.getValues()) {
|
for (Object value : values.getValues()) {
|
||||||
doc.add(new StringField(name, (String) value, store));
|
doc.add(new StringField(name, (String) value, store));
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ public class QueryBuilder<V> {
|
|||||||
return intRangeQuery(p);
|
return intRangeQuery(p);
|
||||||
} else if (type == FieldType.TIMESTAMP) {
|
} else if (type == FieldType.TIMESTAMP) {
|
||||||
return timestampQuery(p);
|
return timestampQuery(p);
|
||||||
} else if (type == FieldType.EXACT || type == FieldType.KEYWORD) {
|
} else if (type == FieldType.EXACT) {
|
||||||
return exactQuery(p);
|
return exactQuery(p);
|
||||||
} else if (type == FieldType.PREFIX) {
|
} else if (type == FieldType.PREFIX) {
|
||||||
return prefixQuery(p);
|
return prefixQuery(p);
|
||||||
|
@ -39,10 +39,6 @@ public final class FieldDef<I, T> {
|
|||||||
return new FieldDef.Builder<>(FieldType.EXACT, name);
|
return new FieldDef.Builder<>(FieldType.EXACT, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FieldDef.Builder<String> keyword(String name) {
|
|
||||||
return new FieldDef.Builder<>(FieldType.KEYWORD, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FieldDef.Builder<String> fullText(String name) {
|
public static FieldDef.Builder<String> fullText(String name) {
|
||||||
return new FieldDef.Builder<>(FieldType.FULL_TEXT, name);
|
return new FieldDef.Builder<>(FieldType.FULL_TEXT, name);
|
||||||
}
|
}
|
||||||
|
@ -33,9 +33,6 @@ public class FieldType<T> {
|
|||||||
/** A string field searched using exact-match semantics. */
|
/** A string field searched using exact-match semantics. */
|
||||||
public static final FieldType<String> EXACT = new FieldType<>("EXACT");
|
public static final FieldType<String> EXACT = new FieldType<>("EXACT");
|
||||||
|
|
||||||
/** A Keyword field searched using non-analyzed-match semantics. */
|
|
||||||
public static final FieldType<String> KEYWORD = new FieldType<>("KEYWORD");
|
|
||||||
|
|
||||||
/** A string field searched using prefix. */
|
/** A string field searched using prefix. */
|
||||||
public static final FieldType<String> PREFIX = new FieldType<>("PREFIX");
|
public static final FieldType<String> PREFIX = new FieldType<>("PREFIX");
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ package com.google.gerrit.server.index.group;
|
|||||||
import static com.google.gerrit.server.index.FieldDef.exact;
|
import static com.google.gerrit.server.index.FieldDef.exact;
|
||||||
import static com.google.gerrit.server.index.FieldDef.fullText;
|
import static com.google.gerrit.server.index.FieldDef.fullText;
|
||||||
import static com.google.gerrit.server.index.FieldDef.integer;
|
import static com.google.gerrit.server.index.FieldDef.integer;
|
||||||
import static com.google.gerrit.server.index.FieldDef.keyword;
|
|
||||||
import static com.google.gerrit.server.index.FieldDef.prefix;
|
import static com.google.gerrit.server.index.FieldDef.prefix;
|
||||||
|
|
||||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||||
@ -32,11 +31,11 @@ public class GroupField {
|
|||||||
|
|
||||||
/** Group UUID. */
|
/** Group UUID. */
|
||||||
public static final FieldDef<AccountGroup, String> UUID =
|
public static final FieldDef<AccountGroup, String> UUID =
|
||||||
keyword("uuid").stored().build(g -> g.getGroupUUID().get());
|
exact("uuid").stored().build(g -> g.getGroupUUID().get());
|
||||||
|
|
||||||
/** Group owner UUID. */
|
/** Group owner UUID. */
|
||||||
public static final FieldDef<AccountGroup, String> OWNER_UUID =
|
public static final FieldDef<AccountGroup, String> OWNER_UUID =
|
||||||
keyword("owner_uuid").build(g -> g.getOwnerGroupUUID().get());
|
exact("owner_uuid").build(g -> g.getOwnerGroupUUID().get());
|
||||||
|
|
||||||
/** Group name. */
|
/** Group name. */
|
||||||
public static final FieldDef<AccountGroup, String> NAME =
|
public static final FieldDef<AccountGroup, String> NAME =
|
||||||
|
Loading…
Reference in New Issue
Block a user