[ 
https://issues.apache.org/jira/browse/JENA-1305?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15938430#comment-15938430
 ] 

ASF GitHub Bot commented on JENA-1305:
--------------------------------------

Github user anujgandharv commented on a diff in the pull request:

    https://github.com/apache/jena/pull/227#discussion_r107681399
  
    --- Diff: 
jena-text/src/test/java/org/apache/jena/query/text/it/TextIndexESIT.java ---
    @@ -0,0 +1,282 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.jena.query.text.it;
    +
    +import org.apache.jena.graph.Node;
    +import org.apache.jena.query.text.Entity;
    +import org.apache.jena.query.text.TextHit;
    +import org.apache.jena.vocabulary.RDFS;
    +import org.elasticsearch.action.get.GetResponse;
    +import org.junit.Assert;
    +import org.junit.Test;
    +
    +import java.util.List;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +/**
    + * Integration test class for {@link 
org.apache.jena.query.text.TextIndexES}
    + */
    +public class TextIndexESIT extends BaseESTest {
    +
    +    @Test
    +    public void testAddEntity() {
    +        String labelKey = "label";
    +        String labelValue = "this is a sample Label";
    +        Assert.assertNotNull(classToTest);
    +        Entity entityToAdd = entity("http://example/x3";, labelKey, 
labelValue);
    +        GetResponse response = addEntity(entityToAdd);
    +        Assert.assertTrue(response.getSource().containsKey(labelKey));
    +        Assert.assertEquals(labelValue, 
((List)response.getSource().get(labelKey)).get(0));
    +    }
    +
    +    @Test
    +    public void testDeleteEntity() {
    +        testAddEntity();
    +        String labelKey = "label";
    +        String labelValue = "this is a sample Label";
    +        //Now Delete the entity
    +        classToTest.deleteEntity(entity("http://example/x3";, labelKey, 
labelValue));
    +
    +        //Try to find it
    +        GetResponse response = transportClient.prepareGet(INDEX_NAME, 
DOC_TYPE, "http://example/x3";).get();
    +        //It Should Exist
    +        Assert.assertTrue(response.isExists());
    +        //But the field value should now be empty
    +        Assert.assertEquals("http://example/x3";, response.getId());
    +        Assert.assertTrue(response.getSource().containsKey(labelKey));
    +        Assert.assertEquals(0, 
((List)response.getSource().get(labelKey)).size());
    +    }
    +
    +    @Test
    +    public void testDeleteWhenNoneExists() {
    +
    +        GetResponse response = transportClient.prepareGet(INDEX_NAME, 
DOC_TYPE, "http://example/x3";).get();
    +        Assert.assertFalse(response.isExists());
    +        Assert.assertNotNull(classToTest);
    +        classToTest.deleteEntity(entity("http://example/x3";, "label", 
"doesnt matter"));
    +        response = transportClient.prepareGet(INDEX_NAME, DOC_TYPE, 
"http://example/x3";).get();
    +        Assert.assertFalse(response.isExists());
    +
    +    }
    +
    +    @Test
    +    public void testQuery() {
    +        testAddEntity();
    +        // This will search for value "this" across all the fields in all 
the documents
    +        List<TextHit> result =  classToTest.query(RDFS.label.asNode(), 
"this", 10);
    +        Assert.assertNotNull(result);
    +        Assert.assertEquals(1, result.size());
    +
    +        //This will search for value "this" only in the label field
    +        result =  classToTest.query(RDFS.label.asNode(), "label:this", 10);
    +        Assert.assertNotNull(result);
    +        Assert.assertEquals(1, result.size());
    +
    +        //This will search for value "this" in the label_en field, if it 
exists. In this case it doesnt so we should get zero results
    +        result =  classToTest.query(RDFS.label.asNode(), "label:this AND 
lang:en", 10);
    +        Assert.assertNotNull(result);
    +        Assert.assertEquals(0, result.size());
    +
    +    }
    +
    +    @Test
    +    public void testQueryWhenNoneExists() {
    +        List<TextHit> result =  classToTest.query(RDFS.label.asNode(), 
"this", 1);
    +        Assert.assertNotNull(result);
    +        Assert.assertEquals(0, result.size());
    +    }
    +
    +    @Test
    +    public void testGet() {
    +        testAddEntity();
    +        //Now Get the same entity
    +        Map<String, Node> response = classToTest.get("http://example/x3";);
    +        Assert.assertNotNull(response);
    +        Assert.assertEquals(2, response.size());
    +    }
    +
    +    @Test
    +    public void testGetWhenNoneExists() {
    +        Map<String, Node> response = classToTest.get("http://example/x3";);
    +        Assert.assertNotNull(response);
    +        Assert.assertEquals(0, response.size());
    +    }
    +
    +    /**
    +     * This is an elaborate test that does the following:
    +     * 1. Create a Document with ID: "http://example/x3"; , label: Germany 
and lang:en
    +     * 2. Makes sure the document is created successfully and is 
searchable based on the label
    +     * 3. Next add another label to the same Entity with ID: 
"http://example/x3";, label:Deutschland and lang:de
    +     * 4. Makes sure that the document is searchable both with old 
(Germany) and new (Deutschland) values.
    +     * 5. Next, it deletes the value: Germany created in step 1.
    +     * 6. Makes sure that document is searchable with value: Deutschland 
but NOT with value: Germany
    +     * 7. Finally, delete the value: Deutschland
    +     * 8. The document should not be searchable with value: Deutschland
    +     * 9. The document should still exist
    +     */
    +    @Test
    +    public void testMultipleValuesinMultipleLanguages() throws 
InterruptedException{
    +        addEntity(entity("http://example/x3";, "label", "Germany", "en"));
    +        List<TextHit> result =  classToTest.query(RDFS.label.asNode(), 
"Germany", 10);
    +        Assert.assertNotNull(result);
    +        Assert.assertEquals(1, result.size());
    +        Assert.assertEquals("http://example/x3";, 
result.get(0).getNode().getURI());
    +        //Next add another label to the same entity
    +        addEntity(entity("http://example/x3";, "label", "Deutschland", 
"de"));
    +        //Query with old value
    +        result =  classToTest.query(RDFS.label.asNode(), "Germany", 10);
    +        Assert.assertEquals(1, result.size());
    +        Assert.assertEquals("http://example/x3";, 
result.get(0).getNode().getURI());
    +
    +        //Query with new value
    +        result =  classToTest.query(RDFS.label.asNode(), "Deutschland", 
10);
    +        Assert.assertEquals(1, result.size());
    +        Assert.assertEquals("http://example/x3";, 
result.get(0).getNode().getURI());
    +
    +        //Now lets delete the German label
    --- End diff --
    
    Done


> Elastic Search Support for Apache Jena Text 
> --------------------------------------------
>
>                 Key: JENA-1305
>                 URL: https://issues.apache.org/jira/browse/JENA-1305
>             Project: Apache Jena
>          Issue Type: New Feature
>          Components: Text
>    Affects Versions: Jena 3.2.0
>            Reporter: Anuj Kumar
>            Assignee: Osma Suominen
>              Labels: elasticsearch
>   Original Estimate: 240h
>  Remaining Estimate: 240h
>
> This Jira tracks the development of Jena Text ElasticSearch Implementation.
> The goal is to extend Jena Text capability to index, at scale, in 
> ElasticSearch. This implementation would be similar to the Lucene and Solr 
> implementations.
> We will use ES version 5.2.1 for the implementation.
> The following functionalities would be supported:
> * Indexing Literal values
> * Updating indexed values
> * Deleting Indexed values
> * Custom Analyzer Support
> * Configuration using Assembler as well as Java techniques.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to