Отображение эластичного поиска Ожидаемая карта для свойства [fields] в поле [name], но полученного класса java .lang.String - PullRequest
0 голосов
/ 23 апреля 2020

Вот мои данные, они основаны на схеме, и мне нужно сгенерировать отображение для индексации на ES. Мой опыт работы с ES невелик, но я думал, что получил его, пока не попробовал и не смог, и не могу найти правильный ответ в Интернете ..

{
  "@context": {
    "schema": "http://schema.org/",
    "outbreak": "https://discovery.biothings.io/view/outbreak/"
  },
  "@type": "outbreak:Publication",
  "keywords": [
    "COVID-19",
    "City lockdown",
    "Epidemic",
    "Governmental action",
    "Individual reaction",
    "Mathematical modelling"
  ],
  "author": [
    {
      "@type": "outbreak:Person",
      "affiliation": [
        {
          "@type": "outbreak:Organization",
          "name": "Department of Applied Mathematics, Hong Kong Polytechnic University, Hong Kong, China. Electronic address: daihai.he@polyu.edu.hk."
        }
      ],
      "familyName": "He",
      "givenName": "Daihai",
      "name": "Daihai He"
    }
  ],
  "publicationType": [
    "Journal Article"
  ],
  "_id": "pmid32145465",
  "curatedBy": {
    "@type": "schema:WebSite",
    "name": "litcovid",
    "url": "https://www.ncbi.nlm.nih.gov/research/coronavirus/publication/32145465"
  },
  "name": "A conceptual model for the coronavirus disease 2019 (COVID-19) outbreak in Wuhan, China with individual reaction and governmental action.",
  "identifier": "32145465",
  "pmid": "32145465",
  "abstract": "The ongoing coronavirus disease 2019 (COVID-19) outbreak, emerged in Wuhan, China in the end of 2019, has claimed more than 2600 lives as of 24 February 2020 and posed a huge threat to global public health. The Chinese government has implemented control measures including setting up special hospitals and travel restriction to mitigate the spread. We propose conceptual models for the COVID-19 outbreak in Wuhan with the consideration of individual behavioural reaction and governmental actions, e.g., holiday extension, travel restriction, hospitalisation and quarantine. We employe the estimates of these two key components from the 1918 influenza pandemic in London, United Kingdom, incorporated zoonotic introductions and the emigration, and then compute future trends and the reporting ratio. The model is concise in structure, and it successfully captures the course of the COVID-19 outbreak, and thus sheds light on understanding the trends of the outbreak.",
  "license": "Copyright © 2020 The Authors. Published by Elsevier Ltd.. All rights reserved.",
  "journalName": "International journal of infectious diseases : IJID : official publication of the International Society for Infectious Diseases",
  "journalAbbreviation": "Int. J. Infect. Dis.",
  "issueNumber": "1878-3511",
  "doi": "S1201-9712(20)30117-X",
  "url": "https://www.doi.org/S1201-9712(20)30117-X",
  "datePublished": "2020-03-04",
  "dateModified": "2020-02-26"
}

и вот мое отображение:

{
                'fields':{
                    'type': 'string'
                },
                'abstract': {
                    'type': 'text'
                },
                'pmid': {
                    'type': 'integer'
                },
                'author': {
                    'type': 'nested',
                    'properties': {
                        'name':{
                            'type': 'text'
                        },
                        'givenName':{
                            'type': 'text'
                        },
                        'familyName':{
                            'type': 'text'
                        },
                        'affiliation':{
                            'type': 'nested',
                            'properties': {
                                'name':{
                                    'type': 'text'
                                }
                            }
                        }
                    }
                },
                'isBasedOn': {
                    'type': 'text'
                },
                'funding': {
                    'type': 'nested',
                    'properties': {
                        'funder':{
                            'type': 'nested',
                            'properties':{
                                'name': 'text'
                            }
                        },
                        'identifier':{
                            'type': 'text'
                        }
                    }
                },
                'license': {
                    'type': 'text'
                },
                'keywords': {
                    'normalizer': 'keyword_lowercase_normalizer',
                    'type': 'keyword',
                    'copy_to': ['all']
                },
                'publicationType': {
                    'normalizer': 'keyword_lowercase_normalizer',
                    'type': 'keyword',
                    'copy_to': ['all']
                },
                'name': {
                    'type': 'text'
                },
                'journalName': {
                    'type': 'text'
                },
                'identifier': {
                    'type': 'text'
                },
                'doi': {
                    'type': 'text'
                },
                'datePublished': {
                    'type': 'date'
                },
                'dateModified': {
                    'type': 'date'
                },
                'issueNumber': {
                    'type': 'text'
                }
         }

В моих данных нет поля «поля», поэтому я не уверен, что это значит, а «имя» - простая строка

Я пробовал это, а также "mappings": {"properties": {...}}, но это также не помогает. Любые указатели ??

Ответы [ 2 ]

0 голосов
/ 23 апреля 2020

В вашем отображении было две проблемы * Использована строка

  1. , это недействительный тип данных, вместо этого используйте текст

  2. ' properties ': {' name ':' text '} должно быть "name": {"type": "text"}

Вы используете нормализатор, я не знаю ваш требование, поэтому проверьте, если вам нужен нормализатор или анализатор

Исправленное отображение

"fields": {
        "type": "text"
      },
      "abstract": {
        "type": "text"
      },
      "pmid": {
        "type": "integer"
      },
      "author": {
        "type": "nested",
        "properties": {
          "name": {
            "type": "text"
          },
          "givenName": {
            "type": "text"
          },
          "familyName": {
            "type": "text"
          },
          "affiliation": {
            "type": "nested",
            "properties": {
              "name": {
                "type": "text"
              }
            }
          }
        }
      },
      "isBasedOn": {
        "type": "text"
      },
      "funding": {
        "type": "nested",
        "properties": {
          "funder": {
            "type": "nested",
            "properties": {
              "name": {
                "type": "text"
              }
            }
          },
          "identifier": {
            "type": "text"
          }
        }
      },
      "license": {
        "type": "text"
      },
      "keywords": {
        "normalizer": "keyword_lowercase_normalizer",
        "type": "keyword",
        "copy_to": [
          "all"
        ]
      },
      "publicationType": {
        "normalizer": "keyword_lowercase_normalizer",
        "type": "keyword",
        "copy_to": [
          "all"
        ]
      },
      "name": {
        "type": "text"
      },
      "journalName": {
        "type": "text"
      },
      "identifier": {
        "type": "text"
      },
      "doi": {
        "type": "text"
      },
      "datePublished": {
        "type": "date"
      },
      "dateModified": {
        "type": "date"
      },
      "issueNumber": {
        "type": "text"
      }

0 голосов
/ 23 апреля 2020

Попробуйте использовать текст или ключевое слово вместо string для поля fields

. Строка не является допустимым типом данных в Elasticsearch. Вы можете использовать ключевое слово или текст

  • Текстовые данные Тип

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

  • Тип данных ключевых слов

    Поле для индексации структурированного контента, такого как идентификаторы, адреса электронной почты, имена хостов, коды состояния, почтовые индексы или теги.

Источник: https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-types.html

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...