diff --git a/zulia-client/src/main/java/io/zulia/fields/FieldConfigBuilder.java b/zulia-client/src/main/java/io/zulia/fields/FieldConfigBuilder.java index c6f96925..6befc3d6 100644 --- a/zulia-client/src/main/java/io/zulia/fields/FieldConfigBuilder.java +++ b/zulia-client/src/main/java/io/zulia/fields/FieldConfigBuilder.java @@ -33,6 +33,34 @@ public static FieldConfigBuilder create(String storedFieldName, FieldConfig.Fiel return new FieldConfigBuilder(storedFieldName, fieldType); } + public static FieldConfigBuilder createString(String storedFieldName) { + return create(storedFieldName, FieldConfig.FieldType.STRING); + } + + public static FieldConfigBuilder createBool(String storedFieldName) { + return create(storedFieldName, FieldConfig.FieldType.BOOL); + } + + public static FieldConfigBuilder createDate(String storedFieldName) { + return create(storedFieldName, FieldConfig.FieldType.DATE); + } + + public static FieldConfigBuilder createInt(String storedFieldName) { + return create(storedFieldName, FieldConfig.FieldType.NUMERIC_INT); + } + + public static FieldConfigBuilder createLong(String storedFieldName) { + return create(storedFieldName, FieldConfig.FieldType.NUMERIC_LONG); + } + + public static FieldConfigBuilder createFloat(String storedFieldName) { + return create(storedFieldName, FieldConfig.FieldType.NUMERIC_FLOAT); + } + + public static FieldConfigBuilder createDouble(String storedFieldName) { + return create(storedFieldName, FieldConfig.FieldType.NUMERIC_DOUBLE); + } + public FieldConfigBuilder index() { return indexAs(null, storedFieldName); } diff --git a/zulia-server/src/test/java/io/zulia/server/test/QueryTest.java b/zulia-server/src/test/java/io/zulia/server/test/QueryTest.java new file mode 100644 index 00000000..f7b41fd0 --- /dev/null +++ b/zulia-server/src/test/java/io/zulia/server/test/QueryTest.java @@ -0,0 +1,60 @@ +package io.zulia.server.test; + +import io.zulia.client.command.builder.ScoredQuery; +import io.zulia.client.command.builder.Search; +import io.zulia.client.command.builder.Sort; +import io.zulia.client.config.ZuliaPoolConfig; +import io.zulia.client.pool.ZuliaWorkPool; +import io.zulia.client.result.SearchResult; +import io.zulia.message.ZuliaQuery; + +public class QueryTest { + + public static void main(String[] args) throws Exception { + ZuliaWorkPool zuliaWorkPool = new ZuliaWorkPool(new ZuliaPoolConfig().addNode("localhost")); + + Search search = new Search("publicgrants20220303"); + search.setAmount(500); + search.addQuery(new ScoredQuery("breast AND cancer").addQueryFields("title", "abstract")); + search.addDocumentFields("title", "abstract"); + + SearchResult searchResult = zuliaWorkPool.search(search); + System.out.println(searchResult.getTotalHits()); + System.out.println("breast AND cancer Top 100," + searchResult.getCommandTimeMs()); + + search.addSort(new Sort("title")); + searchResult = zuliaWorkPool.search(search); + System.out.println("breast AND cancer Top 100 Sort Title," + searchResult.getCommandTimeMs()); + + search.clearSort(); + long start = System.currentTimeMillis(); + zuliaWorkPool.searchAllAsDocument(search, document -> { + //no-op + }); + long end = System.currentTimeMillis(); + System.out.println("breast AND cancer All Matches," + (end-start)); + + search.setResultFetchType(ZuliaQuery.FetchType.NONE); + search.clearSort(); + search.clearLastResult(); + search.addSort(new Sort("id")); + start = System.currentTimeMillis(); + zuliaWorkPool.searchAllAsScoredResult(search, scoredResult -> { + //no-op + }); + end = System.currentTimeMillis(); + System.out.println("breast AND cancer All Matches Sort Id (None)," + (end-start)); + + search.setResultFetchType(ZuliaQuery.FetchType.FULL); + search.clearSort(); + search.clearLastResult(); + search.addSort(new Sort("id")); + start = System.currentTimeMillis(); + zuliaWorkPool.searchAllAsDocument(search, document -> { + //no-op + }); + end = System.currentTimeMillis(); + System.out.println("breast AND cancer All Matches Sort Id (Full)," + (end-start)); + + } +} diff --git a/zulia-server/src/test/java/io/zulia/server/test/node/AliasTest.java b/zulia-server/src/test/java/io/zulia/server/test/node/AliasTest.java index 207b287c..27945302 100644 --- a/zulia-server/src/test/java/io/zulia/server/test/node/AliasTest.java +++ b/zulia-server/src/test/java/io/zulia/server/test/node/AliasTest.java @@ -18,7 +18,6 @@ import io.zulia.client.result.SearchResult; import io.zulia.doc.ResultDocBuilder; import io.zulia.fields.FieldConfigBuilder; -import io.zulia.message.ZuliaIndex.FieldConfig.FieldType; import org.bson.Document; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; @@ -49,9 +48,9 @@ public static void initAll() throws Exception { ClientIndexConfig indexConfig = new ClientIndexConfig(); indexConfig.addDefaultSearchField("title"); - indexConfig.addFieldConfig(FieldConfigBuilder.create("id", FieldType.STRING).indexAs(DefaultAnalyzers.LC_KEYWORD).sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("title", FieldType.STRING).indexAs(DefaultAnalyzers.STANDARD).sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("rating", FieldType.NUMERIC_DOUBLE).index().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("id").indexAs(DefaultAnalyzers.LC_KEYWORD).sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("title").indexAs(DefaultAnalyzers.STANDARD).sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createDouble("rating").index().sort()); indexConfig.setIndexName(ALIAS_TEST_INDEX); indexConfig.setNumberOfShards(1); indexConfig.setShardCommitInterval(20); //force some commits diff --git a/zulia-server/src/test/java/io/zulia/server/test/node/HierarchicalFacetTest.java b/zulia-server/src/test/java/io/zulia/server/test/node/HierarchicalFacetTest.java index c5f24ef0..dd1359c3 100644 --- a/zulia-server/src/test/java/io/zulia/server/test/node/HierarchicalFacetTest.java +++ b/zulia-server/src/test/java/io/zulia/server/test/node/HierarchicalFacetTest.java @@ -9,7 +9,6 @@ import io.zulia.client.result.SearchResult; import io.zulia.doc.ResultDocBuilder; import io.zulia.fields.FieldConfigBuilder; -import io.zulia.message.ZuliaIndex.FieldConfig.FieldType; import io.zulia.message.ZuliaQuery.FacetCount; import org.bson.Document; import org.junit.jupiter.api.Assertions; @@ -51,12 +50,12 @@ public static void initAll() throws Exception { ClientIndexConfig indexConfig = new ClientIndexConfig(); indexConfig.addDefaultSearchField("title"); - indexConfig.addFieldConfig(FieldConfigBuilder.create("id", FieldType.STRING).indexAs(DefaultAnalyzers.LC_KEYWORD).sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("title", FieldType.STRING).indexAs(DefaultAnalyzers.STANDARD).sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("path", FieldType.STRING).indexAs(DefaultAnalyzers.LC_KEYWORD).facetHierarchical().sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("date", FieldType.DATE).index().facetHierarchical().sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("normalFacet", FieldType.STRING).indexAs(DefaultAnalyzers.LC_KEYWORD).facet().sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("normalFacetList", FieldType.STRING).indexAs(DefaultAnalyzers.LC_KEYWORD).facet().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("id").indexAs(DefaultAnalyzers.LC_KEYWORD).sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("title").indexAs(DefaultAnalyzers.STANDARD).sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("path").indexAs(DefaultAnalyzers.LC_KEYWORD).facetHierarchical().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createDate("date").index().facetHierarchical().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("normalFacet").indexAs(DefaultAnalyzers.LC_KEYWORD).facet().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("normalFacetList").indexAs(DefaultAnalyzers.LC_KEYWORD).facet().sort()); indexConfig.setIndexName(FACET_TEST_INDEX); indexConfig.setNumberOfShards(1); indexConfig.setShardCommitInterval(20); //force some commits @@ -226,11 +225,11 @@ else if (path.getFacet().equals("3")) { public void reindex() throws Exception { ClientIndexConfig indexConfig = new ClientIndexConfig(); indexConfig.addDefaultSearchField("title"); - indexConfig.addFieldConfig(FieldConfigBuilder.create("id", FieldType.STRING).indexAs(DefaultAnalyzers.LC_KEYWORD).sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("title", FieldType.STRING).indexAs(DefaultAnalyzers.STANDARD).sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("path", FieldType.STRING).indexAs(DefaultAnalyzers.LC_KEYWORD).facetHierarchical().sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("path2", FieldType.STRING).indexAs(DefaultAnalyzers.LC_KEYWORD).facetHierarchical().sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("date", FieldType.DATE).index().facetHierarchical().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("id").indexAs(DefaultAnalyzers.LC_KEYWORD).sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("title").indexAs(DefaultAnalyzers.STANDARD).sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("path").indexAs(DefaultAnalyzers.LC_KEYWORD).facetHierarchical().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("path2").indexAs(DefaultAnalyzers.LC_KEYWORD).facetHierarchical().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createDate("date").index().facetHierarchical().sort()); indexConfig.setIndexName(FACET_TEST_INDEX); indexConfig.setNumberOfShards(1); indexConfig.setShardCommitInterval(20); //force some commits diff --git a/zulia-server/src/test/java/io/zulia/server/test/node/SortTest.java b/zulia-server/src/test/java/io/zulia/server/test/node/SortTest.java index f93b401e..a1cb1038 100644 --- a/zulia-server/src/test/java/io/zulia/server/test/node/SortTest.java +++ b/zulia-server/src/test/java/io/zulia/server/test/node/SortTest.java @@ -12,7 +12,6 @@ import io.zulia.client.result.SearchResult; import io.zulia.doc.ResultDocBuilder; import io.zulia.fields.FieldConfigBuilder; -import io.zulia.message.ZuliaIndex.FieldConfig.FieldType; import org.bson.Document; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; @@ -54,14 +53,14 @@ public void indexingTest() throws Exception { ClientIndexConfig indexConfig = new ClientIndexConfig(); indexConfig.addDefaultSearchField("title"); - indexConfig.addFieldConfig(FieldConfigBuilder.create("id", FieldType.STRING).indexAs(DefaultAnalyzers.LC_KEYWORD).sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("title", FieldType.STRING).indexAs(DefaultAnalyzers.STANDARD).sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("stars", FieldType.NUMERIC_INT).index().sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("starsLong", FieldType.NUMERIC_LONG).index().sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("rating", FieldType.NUMERIC_FLOAT).index().sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("ratingDouble", FieldType.NUMERIC_FLOAT).index().sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("special", FieldType.BOOL).index().sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("added", FieldType.DATE).index().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("id").indexAs(DefaultAnalyzers.LC_KEYWORD).sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("title").indexAs(DefaultAnalyzers.STANDARD).sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createInt("stars").index().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createLong("starsLong").index().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createFloat("rating").index().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createFloat("ratingDouble").index().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createBool("special").index().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createDate("added").index().sort()); indexConfig.setIndexName(INDEX_NAME); indexConfig.setNumberOfShards(1); indexConfig.setShardCommitInterval(20); //force some commits @@ -523,18 +522,18 @@ public void afterRestartRetry() throws Exception { public void reindexTest() throws Exception { ClientIndexConfig indexConfig = new ClientIndexConfig(); indexConfig.addDefaultSearchField("title"); - indexConfig.addFieldConfig(FieldConfigBuilder.create("id", FieldType.STRING).indexAs(DefaultAnalyzers.LC_KEYWORD) + indexConfig.addFieldConfig(FieldConfigBuilder.createString("id").indexAs(DefaultAnalyzers.LC_KEYWORD) .sortAs("theId")); //change sort as to be theId instead of just id - indexConfig.addFieldConfig(FieldConfigBuilder.create("title", FieldType.STRING).indexAs(DefaultAnalyzers.STANDARD).sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("stars", FieldType.NUMERIC_INT).index()); // no longer sortable - indexConfig.addFieldConfig(FieldConfigBuilder.create("starsLong", FieldType.NUMERIC_LONG).index().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("title").indexAs(DefaultAnalyzers.STANDARD).sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createInt("stars").index()); // no longer sortable + indexConfig.addFieldConfig(FieldConfigBuilder.createLong("starsLong").index().sort()); //indexConfig.addFieldConfig(FieldConfigBuilder.create("rating", FieldType.NUMERIC_FLOAT).index().sort()); // no longer indexed or sortable - indexConfig.addFieldConfig(FieldConfigBuilder.create("ratingDouble", FieldType.NUMERIC_FLOAT).index().sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("special", FieldType.BOOL).index().sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("added", FieldType.DATE).index().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createFloat("ratingDouble").index().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createBool("special").index().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createDate("added").index().sort()); //sort() adds standard string (case senstive sorting with a field name the same as the stored field //sortAs(LOWERCASE_FOLDING, "otherTitleFolding") add another sortable field with a lowercase and ascii folding filter applied to make case insensitive sort and fancy letter insensitive (gotta be a better term here) - indexConfig.addFieldConfig(FieldConfigBuilder.create("otherTitle", FieldType.STRING).index().sort().sortAs(LOWERCASE_FOLDING, "otherTitleFolding")); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("otherTitle").index().sort().sortAs(LOWERCASE_FOLDING, "otherTitleFolding")); indexConfig.setIndexName(INDEX_NAME); indexConfig.setNumberOfShards(1); indexConfig.setShardCommitInterval(20); //force some commits @@ -574,8 +573,8 @@ public void multiIndexTest() throws Exception { ClientIndexConfig indexConfig = new ClientIndexConfig(); indexConfig.addDefaultSearchField("magicNumber"); - indexConfig.addFieldConfig(FieldConfigBuilder.create("id", FieldType.NUMERIC_INT).sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("magicNumber", FieldType.NUMERIC_INT).index().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createInt("id").sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createInt("magicNumber").index().sort()); indexConfig.setIndexName("anotherIndex"); indexConfig.setNumberOfShards(1); indexConfig.setShardCommitInterval(20); //force some commits diff --git a/zulia-server/src/test/java/io/zulia/server/test/node/StartStopTest.java b/zulia-server/src/test/java/io/zulia/server/test/node/StartStopTest.java index d4d070b0..72ef9a0d 100644 --- a/zulia-server/src/test/java/io/zulia/server/test/node/StartStopTest.java +++ b/zulia-server/src/test/java/io/zulia/server/test/node/StartStopTest.java @@ -17,7 +17,6 @@ import io.zulia.doc.ResultDocBuilder; import io.zulia.fields.FieldConfigBuilder; import io.zulia.message.ZuliaIndex.FacetAs.DateHandling; -import io.zulia.message.ZuliaIndex.FieldConfig.FieldType; import io.zulia.message.ZuliaQuery; import io.zulia.message.ZuliaQuery.FacetCount; import io.zulia.util.ZuliaUtil; @@ -65,16 +64,16 @@ public static void initAll() throws Exception { ClientIndexConfig indexConfig = new ClientIndexConfig(); indexConfig.addDefaultSearchField("title"); - indexConfig.addFieldConfig(FieldConfigBuilder.create("id", FieldType.STRING).indexAs(DefaultAnalyzers.LC_KEYWORD).sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("title", FieldType.STRING).indexAs(DefaultAnalyzers.STANDARD).sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("issn", FieldType.STRING).indexAs(DefaultAnalyzers.LC_KEYWORD).facet().sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("eissn", FieldType.STRING).indexAs(DefaultAnalyzers.LC_KEYWORD)); - indexConfig.addFieldConfig(FieldConfigBuilder.create("uid", FieldType.STRING).indexAs(DefaultAnalyzers.LC_KEYWORD)); - indexConfig.addFieldConfig(FieldConfigBuilder.create("an", FieldType.NUMERIC_INT).index().sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("country", FieldType.STRING).indexAs(DefaultAnalyzers.LC_KEYWORD).facet()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("date", FieldType.DATE).index().facetAs(DateHandling.DATE_YYYY_MM_DD).sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("testList", FieldType.STRING).index()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("testBool", FieldType.BOOL).index().facet().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("id").indexAs(DefaultAnalyzers.LC_KEYWORD).sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("title").indexAs(DefaultAnalyzers.STANDARD).sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("issn").indexAs(DefaultAnalyzers.LC_KEYWORD).facet().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("eissn").indexAs(DefaultAnalyzers.LC_KEYWORD)); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("uid").indexAs(DefaultAnalyzers.LC_KEYWORD)); + indexConfig.addFieldConfig(FieldConfigBuilder.createInt("an").index().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("country").indexAs(DefaultAnalyzers.LC_KEYWORD).facet()); + indexConfig.addFieldConfig(FieldConfigBuilder.createDate("date").index().facetAs(DateHandling.DATE_YYYY_MM_DD).sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("testList").index()); + indexConfig.addFieldConfig(FieldConfigBuilder.createBool("testBool").index().facet().sort()); indexConfig.setIndexName(FACET_TEST_INDEX); indexConfig.setNumberOfShards(1); indexConfig.setShardCommitInterval(20); //force some commits @@ -370,16 +369,16 @@ public void termTestBuilder() throws Exception { public void reindex() throws Exception { ClientIndexConfig indexConfig = new ClientIndexConfig(); indexConfig.addDefaultSearchField("title"); - indexConfig.addFieldConfig(FieldConfigBuilder.create("id", FieldType.STRING).indexAs(DefaultAnalyzers.LC_KEYWORD).sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("title", FieldType.STRING).indexAs(DefaultAnalyzers.STANDARD).sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("issn", FieldType.STRING).indexAs(DefaultAnalyzers.LC_KEYWORD).facet().sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("eissn", FieldType.STRING).indexAs(DefaultAnalyzers.LC_KEYWORD).facet()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("uid", FieldType.STRING).indexAs(DefaultAnalyzers.LC_KEYWORD)); - indexConfig.addFieldConfig(FieldConfigBuilder.create("an", FieldType.NUMERIC_INT).index().displayName("Accession Number").sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("country", FieldType.STRING).indexAs(DefaultAnalyzers.LC_KEYWORD).facet().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("id").indexAs(DefaultAnalyzers.LC_KEYWORD).sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("title").indexAs(DefaultAnalyzers.STANDARD).sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("issn").indexAs(DefaultAnalyzers.LC_KEYWORD).facet().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("eissn").indexAs(DefaultAnalyzers.LC_KEYWORD).facet()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("uid").indexAs(DefaultAnalyzers.LC_KEYWORD)); + indexConfig.addFieldConfig(FieldConfigBuilder.createInt("an").index().displayName("Accession Number").sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("country").indexAs(DefaultAnalyzers.LC_KEYWORD).facet().sort()); indexConfig.addFieldConfig( - FieldConfigBuilder.create("date", FieldType.DATE).index().facetAs(DateHandling.DATE_YYYY_MM_DD).description("The very special data").sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("testList", FieldType.STRING).index()); + FieldConfigBuilder.createDate("date").index().facetAs(DateHandling.DATE_YYYY_MM_DD).description("The very special data").sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("testList").index()); indexConfig.setIndexName(FACET_TEST_INDEX); indexConfig.setNumberOfShards(1); diff --git a/zulia-server/src/test/java/io/zulia/server/test/node/StatTest.java b/zulia-server/src/test/java/io/zulia/server/test/node/StatTest.java index ffbbca9a..c80610a3 100644 --- a/zulia-server/src/test/java/io/zulia/server/test/node/StatTest.java +++ b/zulia-server/src/test/java/io/zulia/server/test/node/StatTest.java @@ -12,7 +12,6 @@ import io.zulia.client.result.SearchResult; import io.zulia.doc.ResultDocBuilder; import io.zulia.fields.FieldConfigBuilder; -import io.zulia.message.ZuliaIndex.FieldConfig.FieldType; import io.zulia.message.ZuliaQuery.FacetStats; import org.bson.Document; import org.junit.jupiter.api.Assertions; @@ -46,12 +45,12 @@ public static void initAll() throws Exception { ClientIndexConfig indexConfig = new ClientIndexConfig(); indexConfig.addDefaultSearchField("title"); - indexConfig.addFieldConfig(FieldConfigBuilder.create("id", FieldType.STRING).indexAs(DefaultAnalyzers.LC_KEYWORD).sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("title", FieldType.STRING).indexAs(DefaultAnalyzers.STANDARD).sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("pathFacet", FieldType.STRING).indexAs(DefaultAnalyzers.LC_KEYWORD).facetHierarchical().sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("normalFacet", FieldType.STRING).indexAs(DefaultAnalyzers.LC_KEYWORD).facet().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("id").indexAs(DefaultAnalyzers.LC_KEYWORD).sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("title").indexAs(DefaultAnalyzers.STANDARD).sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("pathFacet").indexAs(DefaultAnalyzers.LC_KEYWORD).facetHierarchical().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("normalFacet").indexAs(DefaultAnalyzers.LC_KEYWORD).facet().sort()); //indexConfig.addFieldConfig(FieldConfigBuilder.create("authorCount", FieldType.NUMERIC_INT).index().sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("rating", FieldType.NUMERIC_DOUBLE).index().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createDouble("rating").index().sort()); indexConfig.setIndexName(STAT_TEST_INDEX); indexConfig.setNumberOfShards(1); indexConfig.setShardCommitInterval(20); //force some commits @@ -89,9 +88,7 @@ private void indexRecord(int id, String title, String pathFacet, String normalFa mongoDocument.put("rating", rating); Store s = new Store(uniqueId, STAT_TEST_INDEX); - - ResultDocBuilder resultDocumentBuilder = ResultDocBuilder.newBuilder().setDocument(mongoDocument); - s.setResultDocument(resultDocumentBuilder); + s.setResultDocument(ResultDocBuilder.from(mongoDocument)); zuliaWorkPool.store(s); } @@ -194,12 +191,12 @@ else if (facetStats.getFacet().equals("top3")) { public void reindex() throws Exception { ClientIndexConfig indexConfig = new ClientIndexConfig(); indexConfig.addDefaultSearchField("title"); - indexConfig.addFieldConfig(FieldConfigBuilder.create("id", FieldType.STRING).indexAs(DefaultAnalyzers.LC_KEYWORD).sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("title", FieldType.STRING).indexAs(DefaultAnalyzers.STANDARD).sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("pathFacet", FieldType.STRING).indexAs(DefaultAnalyzers.LC_KEYWORD).facetHierarchical().sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("normalFacet", FieldType.STRING).indexAs(DefaultAnalyzers.LC_KEYWORD).facet().sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("authorCount", FieldType.NUMERIC_INT).index().sort()); - indexConfig.addFieldConfig(FieldConfigBuilder.create("rating", FieldType.NUMERIC_DOUBLE).index().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("id").indexAs(DefaultAnalyzers.LC_KEYWORD).sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("title").indexAs(DefaultAnalyzers.STANDARD).sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("pathFacet").indexAs(DefaultAnalyzers.LC_KEYWORD).facetHierarchical().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("normalFacet").indexAs(DefaultAnalyzers.LC_KEYWORD).facet().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createInt("authorCount").index().sort()); + indexConfig.addFieldConfig(FieldConfigBuilder.createDouble("rating").index().sort()); indexConfig.setIndexName(STAT_TEST_INDEX); indexConfig.setNumberOfShards(1); indexConfig.setShardCommitInterval(20); //force some commits diff --git a/zulia-server/src/test/java/io/zulia/server/test/util/FileStorageTest.java b/zulia-server/src/test/java/io/zulia/server/test/util/FileStorageTest.java index ac994152..9bf2d26e 100644 --- a/zulia-server/src/test/java/io/zulia/server/test/util/FileStorageTest.java +++ b/zulia-server/src/test/java/io/zulia/server/test/util/FileStorageTest.java @@ -107,17 +107,17 @@ private void createIndex() throws Exception { indexConfig.addAnalyzerSetting(ZuliaIndex.AnalyzerSettings.newBuilder().setName("entity").addFilter(ZuliaIndex.AnalyzerSettings.Filter.LOWERCASE) .addFilter(ZuliaIndex.AnalyzerSettings.Filter.ASCII_FOLDING).build()); - FieldConfigBuilder fieldConfigBuilder = FieldConfigBuilder.create("title", ZuliaIndex.FieldConfig.FieldType.STRING); + FieldConfigBuilder fieldConfigBuilder = FieldConfigBuilder.createString("title"); fieldConfigBuilder.indexAs("text", "title"); fieldConfigBuilder.displayName("Title"); indexConfig.addFieldConfig(fieldConfigBuilder); - FieldConfigBuilder fieldConfigBuilder2 = FieldConfigBuilder.create("abstract", ZuliaIndex.FieldConfig.FieldType.STRING); + FieldConfigBuilder fieldConfigBuilder2 = FieldConfigBuilder.createString("abstract"); fieldConfigBuilder2.indexAs("text", "abstract"); fieldConfigBuilder2.displayName("Abstract"); indexConfig.addFieldConfig(fieldConfigBuilder2); - FieldConfigBuilder fieldConfigBuilder3 = FieldConfigBuilder.create("id", ZuliaIndex.FieldConfig.FieldType.STRING); + FieldConfigBuilder fieldConfigBuilder3 = FieldConfigBuilder.createString("id"); fieldConfigBuilder3.indexAs(DefaultAnalyzers.STANDARD, "id"); fieldConfigBuilder3.displayName("ID"); indexConfig.addFieldConfig(fieldConfigBuilder3); @@ -155,10 +155,8 @@ private String getRandomString() { int targetStringLength = 10; Random random = new Random(); - String generatedString = random.ints(leftLimit, rightLimit + 1).limit(targetStringLength) + return random.ints(leftLimit, rightLimit + 1).limit(targetStringLength) .collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append).toString(); - - return generatedString; } }