Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Text 弹性搜索与自由格式文本_Text_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Field - Fatal编程技术网 elasticsearch,field,Text,elasticsearch,Field" /> elasticsearch,field,Text,elasticsearch,Field" />

Text 弹性搜索与自由格式文本

Text 弹性搜索与自由格式文本,text,elasticsearch,field,Text,elasticsearch,Field,我不熟悉Elasticsearch。我能找到的所有示例、教程和问题似乎都表明Elasticsearch要求将文档格式化为字段值关系。是否可以搜索格式中没有特定键值关系的自由格式文本文档或日志?如果是这样的话,有人能给我举个例子/文档吗?是的,完全可以这样做,只创建一个包含所有自由格式文本的文档。它将非常好地工作,因为ElasticSearch非常适合文本搜索。 您可以完全索引文档,例如: { text : " An alpaca (Vicugna pacos) is a domesticated

我不熟悉Elasticsearch。我能找到的所有示例、教程和问题似乎都表明Elasticsearch要求将文档格式化为字段值关系。是否可以搜索格式中没有特定键值关系的自由格式文本文档或日志?如果是这样的话,有人能给我举个例子/文档吗?

是的,完全可以这样做,只创建一个包含所有自由格式文本的文档。它将非常好地工作,因为ElasticSearch非常适合文本搜索。 您可以完全索引文档,例如:

{ text : "
An alpaca (Vicugna pacos) is a domesticated species of South American camelid. It resembles a small llama in appearance. There are two breeds of alpaca; the Suri alpaca and the Huacaya alpaca. Alpacas are kept in herds that graze on the level heights of the Andes of southern Peru, northern Bolivia, Ecuador, and northern Chile at an altitude of 3,500 m (11,500 ft) to 5,000 m (16,000 ft) above sea level, throughout the year.[1] Alpacas are considerably smaller than llamas, and unlike llamas, they were not bred to be beasts of burden, but were bred specifically for their fiber. Alpaca fiber is used for making knitted and woven items, similar to wool. These items include blankets, sweaters, hats, gloves, scarves, a wide variety of textiles and ponchos in South America, and sweaters, socks, coats and bedding in other parts of the world. The fiber comes in more than 52 natural colors as classified in Peru, 12 as classified in Australia and 16 as classified in the United States.[2]
"}
如果您这样做,并且您知道您的所有文本都将使用英语或其他语言,那么您应该指定一个到ElasticSearch的映射,例如创建映射、索引和搜索:

PUT /freetext 
{
  "mappings": {
    "properties" : {
        "text" : {
            "type" : "string",
            "analyzer": "english"
        }
    }
  }
}

PUT /freetext/text/alpaga
{
    "text" : "alpaga are awesome"
}

GET /freetext/text/_search?q="alpaga"
您可能会对更具体的分析器感兴趣,我认为这一个很好:

但在做这件事之前,你应该考虑一下你的数据,我相信你总会找到其他的领域。例如,您可能希望使用特定字段(日期、IP、应用程序名称、信息类型(错误、警告、信息))为日志编制索引。 大多数文本文档都有作者和日期列表

通过分离这些特殊信息并告诉Elastic Search有哪些信息(不应分析的日期和文本),您将能够进行如下搜索:

{ text : "
An alpaca (Vicugna pacos) is a domesticated species of South American camelid. It resembles a small llama in appearance. There are two breeds of alpaca; the Suri alpaca and the Huacaya alpaca. Alpacas are kept in herds that graze on the level heights of the Andes of southern Peru, northern Bolivia, Ecuador, and northern Chile at an altitude of 3,500 m (11,500 ft) to 5,000 m (16,000 ft) above sea level, throughout the year.[1] Alpacas are considerably smaller than llamas, and unlike llamas, they were not bred to be beasts of burden, but were bred specifically for their fiber. Alpaca fiber is used for making knitted and woven items, similar to wool. These items include blankets, sweaters, hats, gloves, scarves, a wide variety of textiles and ponchos in South America, and sweaters, socks, coats and bedding in other parts of the world. The fiber comes in more than 52 natural colors as classified in Peru, 12 as classified in Australia and 16 as classified in the United States.[2]
"}
  • 给我过去两天所有关于错误的日志
  • 给我算一下每个作者的文章数