Search in sources :

Example 11 with SearchDocument

use of org.springframework.data.elasticsearch.core.document.SearchDocument in project spring-data-elasticsearch by spring-projects.

the class DocumentAdaptersUnitTests method searchResponseShouldReturnContainsValue.

// DATAES-628
@Test
public void searchResponseShouldReturnContainsValue() {
    Map<String, DocumentField> fields = new LinkedHashMap<>();
    fields.put("string", new DocumentField("string", Collections.singletonList("value")));
    fields.put("bool", new DocumentField("bool", Arrays.asList(true, true, false)));
    fields.put("null", new DocumentField("null", Collections.emptyList()));
    SearchHit searchHit = new SearchHit(123, "my-id", new Text("type"), fields, null);
    SearchDocument document = DocumentAdapters.from(searchHit);
    assertThat(document.containsValue("value")).isTrue();
    assertThat(document.containsValue(Arrays.asList(true, true, false))).isTrue();
    assertThat(document.containsValue(null)).isTrue();
}
Also used : DocumentField(org.elasticsearch.common.document.DocumentField) SearchHit(org.elasticsearch.search.SearchHit) Text(org.elasticsearch.common.text.Text) LinkedHashMap(java.util.LinkedHashMap) SearchDocument(org.springframework.data.elasticsearch.core.document.SearchDocument) Test(org.junit.jupiter.api.Test)

Aggregations

SearchDocument (org.springframework.data.elasticsearch.core.document.SearchDocument)11 SearchHit (org.elasticsearch.search.SearchHit)7 Test (org.junit.jupiter.api.Test)7 Text (org.elasticsearch.common.text.Text)5 LinkedHashMap (java.util.LinkedHashMap)4 DocumentField (org.elasticsearch.common.document.DocumentField)4 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 ShardId (org.elasticsearch.index.shard.ShardId)2 SearchShardTarget (org.elasticsearch.search.SearchShardTarget)2 DisplayName (org.junit.jupiter.api.DisplayName)2 UncategorizedElasticsearchException (org.springframework.data.elasticsearch.UncategorizedElasticsearchException)2 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Log (org.apache.commons.logging.Log)1 LogFactory (org.apache.commons.logging.LogFactory)1 Version (org.elasticsearch.Version)1 DocWriteResponse (org.elasticsearch.action.DocWriteResponse)1