use of io.zulia.client.command.Store in project zuliasearch by zuliaio.
the class FileStorageTest method indexDocument.
private void indexDocument(Document document) throws Exception {
Store store = new Store(document.getString("id"), TEST_INDEX);
store.setResultDocument(new ResultDocBuilder().setDocument(document));
zuliaWorkPool.store(store);
}
use of io.zulia.client.command.Store in project zuliasearch by zuliaio.
the class SortTest method multiIndexTest.
@Test
@Order(14)
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.setIndexName("anotherIndex");
indexConfig.setNumberOfShards(1);
// force some commits
indexConfig.setShardCommitInterval(20);
zuliaWorkPool.createIndex(indexConfig);
indexConfig.setIndexName("anotherIndex2");
zuliaWorkPool.createIndex(indexConfig);
for (int id = 0; id < 200; id++) {
int magicNumber = 7;
if (id > 10) {
magicNumber = -1;
}
Document mongoDocument = new Document().append("id", id).append("magicNumber", magicNumber);
zuliaWorkPool.store(new Store(id + "", "anotherIndex", ResultDocBuilder.from(mongoDocument)));
}
for (int id = 0; id < 100; id++) {
int magicNumber = (id % 10) + 5;
Document mongoDocument = new Document().append("id", id).append("magicNumber", magicNumber);
zuliaWorkPool.store(new Store(id + "", "anotherIndex2", ResultDocBuilder.from(mongoDocument)));
}
SearchResult searchResult;
Search search = new Search("anotherIndex", "anotherIndex2").setAmount(1);
search.addSort(new Sort("magicNumber"));
searchResult = zuliaWorkPool.search(search);
Assertions.assertEquals(-1, searchResult.getFirstDocument().get("magicNumber"));
search.clearSort();
search.addSort(new Sort("magicNumber").descending());
searchResult = zuliaWorkPool.search(search);
Assertions.assertEquals(14, searchResult.getFirstDocument().get("magicNumber"));
}
use of io.zulia.client.command.Store in project zuliasearch by zuliaio.
the class StartStopTest method indexRecord.
private void indexRecord(int id, String issn, String eissn, int i) throws Exception {
boolean half = (i % 2 == 0);
boolean tenth = (i % 10 == 0);
String uniqueId = uniqueIdPrefix + id;
Document mongoDocument = new Document();
mongoDocument.put("issn", issn);
mongoDocument.put("eissn", eissn);
mongoDocument.put("id", id);
if (id != 0) {
mongoDocument.put("an", id);
}
if (id == 0) {
mongoDocument.put("testBool", true);
} else if (id == 1) {
mongoDocument.put("testBool", 1);
} else if (id == 2) {
mongoDocument.put("testBool", "Yes");
} else if (id == 3) {
mongoDocument.put("testBool", "true");
} else if (id == 4) {
mongoDocument.put("testBool", "Y");
} else if (id == 5) {
mongoDocument.put("testBool", "T");
} else if (id == 6) {
mongoDocument.put("testBool", false);
} else if (id == 7) {
mongoDocument.put("testBool", "False");
} else if (id == 8) {
mongoDocument.put("testBool", "F");
} else if (id == 9) {
mongoDocument.put("testBool", 0);
}
if (!issn.equals("3331-3333")) {
if (half) {
mongoDocument.put("title", "Facet Userguide");
} else {
mongoDocument.put("title", "Special Userguide");
}
}
if (half) {
// 1/2 of input
mongoDocument.put("country", "US");
mongoDocument.put("testList", Arrays.asList("one", "two"));
} else {
// 1/2 of input
mongoDocument.put("country", "France");
mongoDocument.put("testList", Arrays.asList("a", "b", "c"));
}
if (tenth) {
// 1/10 of input
Date d = Date.from(LocalDate.of(2014, Month.OCTOBER, 4).atStartOfDay(ZoneId.of("UTC")).toInstant());
mongoDocument.put("date", d);
} else if (half) {
// 2/5 of input
Date d = Date.from(LocalDate.of(2013, Month.SEPTEMBER, 4).atStartOfDay(ZoneId.of("UTC")).toInstant());
mongoDocument.put("date", d);
} else {
// 1/2 of input
Date d = Date.from(LocalDate.of(2012, 8, 4).atStartOfDay(ZoneId.of("UTC")).toInstant());
mongoDocument.put("date", d);
}
Store s = new Store(uniqueId, FACET_TEST_INDEX);
ResultDocBuilder resultDocumentBuilder = ResultDocBuilder.newBuilder().setDocument(mongoDocument);
if (half) {
resultDocumentBuilder.setMetadata(new Document("test", "someValue"));
}
s.setResultDocument(resultDocumentBuilder);
zuliaWorkPool.store(s);
}
use of io.zulia.client.command.Store in project zuliasearch by zuliaio.
the class StatTest method indexRecord.
private void indexRecord(int id, String title, String pathFacet, String normalFacet, int authorCount, List<Double> rating) throws Exception {
String uniqueId = "" + id;
Document mongoDocument = new Document();
mongoDocument.put("id", uniqueId);
mongoDocument.put("title", title);
mongoDocument.put("pathFacet", pathFacet);
mongoDocument.put("normalFacet", normalFacet);
mongoDocument.put("authorCount", authorCount);
mongoDocument.put("rating", rating);
Store s = new Store(uniqueId, STAT_TEST_INDEX);
ResultDocBuilder resultDocumentBuilder = ResultDocBuilder.newBuilder().setDocument(mongoDocument);
s.setResultDocument(resultDocumentBuilder);
zuliaWorkPool.store(s);
}
use of io.zulia.client.command.Store in project zuliasearch by zuliaio.
the class HierarchicalFacetTest method indexRecord.
private void indexRecord(int id, String path, int i) throws Exception {
boolean half = (i % 2 == 0);
boolean tenth = (i % 10 == 0);
String uniqueId = "mySpecialId-" + id;
Document mongoDocument = new Document();
mongoDocument.put("path", path);
mongoDocument.put("path2", path);
mongoDocument.put("normalFacet", path);
mongoDocument.put("id", id);
if (tenth) {
// 1/10 of input
Date d = Date.from(LocalDate.of(2014, Month.OCTOBER, 4).atStartOfDay(ZoneId.of("UTC")).toInstant());
mongoDocument.put("date", d);
} else if (half) {
// 2/5 of input
Date d = Date.from(LocalDate.of(2013, Month.SEPTEMBER, 4).atStartOfDay(ZoneId.of("UTC")).toInstant());
mongoDocument.put("date", d);
mongoDocument.put("normalFacetList", Arrays.asList("value1", "something"));
} else {
// 1/2 of input
Date d = Date.from(LocalDate.of(2012, 8, 4).atStartOfDay(ZoneId.of("UTC")).toInstant());
mongoDocument.put("date", d);
mongoDocument.put("normalFacetList", Arrays.asList("value2", "something2"));
}
Store s = new Store(uniqueId, FACET_TEST_INDEX);
ResultDocBuilder resultDocumentBuilder = ResultDocBuilder.newBuilder().setDocument(mongoDocument);
s.setResultDocument(resultDocumentBuilder);
zuliaWorkPool.store(s);
}
Aggregations