Лучшая практика для поиска вложенных вложений в документах (2 000+ документов с вложенными вложениями) - PullRequest
0 голосов
/ 24 июня 2018

Я извлекаю проиндексированные документы из упругого поиска, используя Java API.Но я получаю Null в качестве ответа от упругого поиска, когда в индексе больше документов, например (2k +).

Если в индексе нет больше документов, чем 500, то приведенный ниже код Java API работает правильно.

Увеличение количества документов в индексе, создающих проблему.(Это что-то вроде проблемы с производительностью во время выборки?)

Я использовал плагин процессора ingest-attachment для вложения, я вложил PDF в свои документы.

Но если я ищу по тому же запросу, используя kibanaсо сценарием curl получаю ответ и могу видеть результаты в Кибане

Пожалуйста, найдите мой код Java ниже

private final static String ATTACHMENT = "document_attachment";
private final static String TYPE = "doc";

public static void main(String args[])
{
    RestHighLevelClient restHighLevelClient = null;

    try {
        restHighLevelClient = new RestHighLevelClient(RestClient.builder(new HttpHost("localhost", 9200, "http"),
                new HttpHost("localhost", 9201, "http")));
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }

    SearchRequest contentSearchRequest = new SearchRequest(ATTACHMENT); 
    SearchSourceBuilder contentSearchSourceBuilder = new SearchSourceBuilder();
    contentSearchRequest.types(TYPE);
    QueryStringQueryBuilder attachmentQB = new QueryStringQueryBuilder("Activa"); 
    attachmentQB.defaultField("attachment.content");
    contentSearchSourceBuilder.query(attachmentQB);
    contentSearchSourceBuilder.size(50);
    contentSearchRequest.source(contentSearchSourceBuilder);
    SearchResponse contentSearchResponse = null;

    try {
        contentSearchResponse = restHighLevelClient.search(contentSearchRequest); // returning null response
    } catch (IOException e) {
        e.getLocalizedMessage();
    }
    System.out.println("Request --->"+contentSearchRequest.toString());
    System.out.println("Response --->"+contentSearchResponse.toString());

    SearchHit[] contentSearchHits = contentSearchResponse.getHits().getHits();
    long contenttotalHits=contentSearchResponse.getHits().totalHits;
    System.out.println("condition Total Hits --->"+contenttotalHits);

Пожалуйста, найдите мой скрипт, который используется в кибане., я получаюответ на приведенный ниже сценарий.

GET document_attachment/_search?pretty
{
  "query" :{
      "match": {"attachment.content": "Activa"}
  }
}

Пожалуйста, найдите ниже запрос поиска от Java API

SearchRequest{searchType=QUERY_THEN_FETCH, indices=[document_attachment], indicesOptions=IndicesOptions[id=38, ignore_unavailable=false, allow_no_indices=true, expand_wildcards_open=true, expand_wildcards_closed=false, allow_aliases_to_multiple_indices=true, forbid_closed_indices=true, ignore_aliases=false], types=[doc], routing='null', preference='null', requestCache=null, scroll=null, maxConcurrentShardRequests=0, batchedReduceSize=512, preFilterShardSize=128, source={"size":50,"query":{"match":{"attachment.content":{"query":"Activa","operator":"OR","prefix_length":0,"max_expansions":50,"fuzzy_transpositions":true,"lenient":false,"zero_terms_query":"NONE","auto_generate_synonyms_phrase_query":true,"boost":1.0}}}}}

Пожалуйста, найдите мои детали отображения

{
  "document_attachment": {
    "mappings": {
      "doc": {
        "properties": {
          "app_language": {
            "type": "text"
          },
          "attachment": {
            "properties": {
              "author": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "content": {
                "type": "text",
                "analyzer": "custom_analyzer"
              },
              "content_length": {
                "type": "long"
              },
              "content_type": {
                "type": "text"
              },
              "date": {
                "type": "date"
              },
              "language": {
                "type": "text"
              },
              "title": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              }
            }
          },
          "catalog_description": {
            "type": "text"
          },
         "fileContent": {
            "type": "text"
          }
         }
        }
      }
    }
  }
}

Пожалуйста, найдите мойподробности настройки

PUT _ingest/pipeline/document_attachment
{
  "description" : "Extract attachment information",
  "processors" : [
    {
      "attachment" : {
        "field" : "fileContent"
      }
    }
  ]
}

Я получаю эту ошибку, только когда пытаюсь выполнить поиск на основе attachment.content, если я выполняю поиск в каком-то другом поле, могу получить результаты.

Использую ElasticSearch 6.2.3 версия

Пожалуйста, найдите ошибку ниже.

org.apache.http.ContentTooLongException: entity content is too long [105539255] for the configured buffer limit [104857600]
    at org.elasticsearch.client.HeapBufferedAsyncResponseConsumer.onEntityEnclosed(HeapBufferedAsyncResponseConsumer.java:76)
    at org.apache.http.nio.protocol.AbstractAsyncResponseConsumer.responseReceived(AbstractAsyncResponseConsumer.java:131)
    at org.apache.http.impl.nio.client.MainClientExec.responseReceived(MainClientExec.java:315)
    at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.responseReceived(DefaultClientExchangeHandlerImpl.java:147)
    at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.responseReceived(HttpAsyncRequestExecutor.java:303)
    at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:255)
    at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:81)
    at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:39)
    at org.apache.http.impl.nio.reactor.AbstractIODispatch.inputReady(AbstractIODispatch.java:114)
    at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:162)
    at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:337)
    at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:315)
    at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:276)
    at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104)
    at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:588)
    at java.lang.Thread.run(Thread.java:748)
Exception in thread "main" java.lang.NullPointerException
    at com.es.utility.DocumentSearch.main(DocumentSearch.java:88)
...