Search in sources :

Example 1 with Document

use of de.tblsoft.solr.pipeline.bean.Document in project solr-cmd-utils by tblsoft.

the class DocumentDifferTest method testCreateField.

@Test
public void testCreateField() {
    Document document1 = DocumentBuilder.document().field("foo", "bar").create();
    Document document2 = DocumentBuilder.document().field("foo", "bar").field("change", "new").create();
    DocumentDiff diff = DocumentDiffer.compare(document1, document2);
    Assert.assertEquals(1, diff.getFieldDiffs().size());
    Assert.assertEquals(FieldDiff.DiffType.CREATE, diff.getFieldDiffs().get(0).getDiffType());
}
Also used : DocumentDiff(de.tblsoft.solr.pipeline.bean.DocumentDiff) Document(de.tblsoft.solr.pipeline.bean.Document) Test(org.junit.Test)

Example 2 with Document

use of de.tblsoft.solr.pipeline.bean.Document in project solr-cmd-utils by tblsoft.

the class DocumentDifferTest method testDeleteField.

@Test
public void testDeleteField() {
    Document document1 = DocumentBuilder.document().field("foo", "bar").field("change", "old").create();
    Document document2 = DocumentBuilder.document().field("foo", "bar").create();
    DocumentDiff diff = DocumentDiffer.compare(document1, document2);
    Assert.assertEquals(1, diff.getFieldDiffs().size());
    Assert.assertEquals(FieldDiff.DiffType.DELETE, diff.getFieldDiffs().get(0).getDiffType());
}
Also used : DocumentDiff(de.tblsoft.solr.pipeline.bean.DocumentDiff) Document(de.tblsoft.solr.pipeline.bean.Document) Test(org.junit.Test)

Example 3 with Document

use of de.tblsoft.solr.pipeline.bean.Document in project solr-cmd-utils by tblsoft.

the class AggregationCountFilterTest method testAggregationCountFilter.

@Test
public void testAggregationCountFilter() {
    configure();
    Document document1 = DocumentBuilder.document().field("field1", "value1").create();
    Document document2 = DocumentBuilder.document().field("field1", "value1").field("field2", "value2").create();
    document(document1, document2);
    sortDocumentListByField("value");
    assertFiled(0, "value", "value1");
    assertFiled(0, "count", "2");
    assertFiled(0, "type", "field1");
    assertFiled(1, "value", "value2");
    assertFiled(1, "count", "1");
    assertFiled(1, "type", "field2");
    assertNumberOfDocuments(2);
    assertNumberOfFields(3);
    assertInitWasDelegated();
    assertEndWasDelegated();
}
Also used : Document(de.tblsoft.solr.pipeline.bean.Document) AbstractFilterTest(de.tblsoft.solr.pipeline.test.AbstractFilterTest) Test(org.junit.Test)

Example 4 with Document

use of de.tblsoft.solr.pipeline.bean.Document in project solr-cmd-utils by tblsoft.

the class CompoundWordFilterTest method testBlumenzwiebel.

@Test
@Ignore
public void testBlumenzwiebel() {
    configure();
    document(DocumentBuilder.document().field("noun", "blumenzwiebel").create(), DocumentBuilder.document().field("noun", "lumen").create(), DocumentBuilder.document().field("noun", "zwiebel").create(), DocumentBuilder.document().field("noun", "deckel").create());
    Document d = outputDocumentList.get(0);
    assertFiledList("tokenized", "maurer", "hammer");
}
Also used : Document(de.tblsoft.solr.pipeline.bean.Document) Ignore(org.junit.Ignore) AbstractFilterTest(de.tblsoft.solr.pipeline.test.AbstractFilterTest) Test(org.junit.Test)

Example 5 with Document

use of de.tblsoft.solr.pipeline.bean.Document in project solr-cmd-utils by tblsoft.

the class BeanTest method testDeleteFieldInDocument.

@Test
public void testDeleteFieldInDocument() {
    Document document = DocumentBuilder.document().field("foo", "bar").field("john", "doe").create();
    document.deleteField("foo");
    Assert.assertNull(document.getField("foo"));
    Assert.assertEquals("doe", document.getFieldValue("john"));
    Assert.assertEquals(1, document.getFields().size());
}
Also used : Document(de.tblsoft.solr.pipeline.bean.Document) Test(org.junit.Test)

Aggregations

Document (de.tblsoft.solr.pipeline.bean.Document)51 ArrayList (java.util.ArrayList)9 Map (java.util.Map)9 Test (org.junit.Test)9 Field (de.tblsoft.solr.pipeline.bean.Field)8 DocumentDiff (de.tblsoft.solr.pipeline.bean.DocumentDiff)4 AbstractFilterTest (de.tblsoft.solr.pipeline.test.AbstractFilterTest)4 GsonBuilder (com.google.gson.GsonBuilder)3 Match (oi.thekraken.grok.api.Match)3 AtomicLongMap (com.google.common.util.concurrent.AtomicLongMap)2 Gson (com.google.gson.Gson)2 JsonElement (com.google.gson.JsonElement)2 DocumentContext (com.jayway.jsonpath.DocumentContext)2 PathNotFoundException (com.jayway.jsonpath.PathNotFoundException)2 DocumentBuilder (de.tblsoft.solr.pipeline.bean.DocumentBuilder)2 SimpleMapping (de.tblsoft.solr.pipeline.filter.SimpleMapping)2 File (java.io.File)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 InputStreamReader (java.io.InputStreamReader)2