Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.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
<img src="//i.stack.imgur.com/RUiNP.png" height="16" width="18" alt="" class="sponsor tag img">elasticsearch Elasticsearch,在URL中搜索域_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Mapping - Fatal编程技术网 elasticsearch Elasticsearch,在URL中搜索域,elasticsearch,mapping,elasticsearch,Mapping" /> elasticsearch Elasticsearch,在URL中搜索域,elasticsearch,mapping,elasticsearch,Mapping" />

elasticsearch Elasticsearch,在URL中搜索域

elasticsearch Elasticsearch,在URL中搜索域,elasticsearch,mapping,elasticsearch,Mapping,我们为HTML文档编制索引,其中可能包含指向其他文档的链接。我们使用的是elasticsearch,对于大多数关键词搜索来说都非常流畅,这非常好 现在,我们正在添加更复杂的搜索,类似于Google站点:或链接:搜索:基本上我们想要检索指向EIHR特定URL甚至域的文档。(如果文档A有到http://a.site.tld/path/,搜索链接:http://a.site.tld应该会产生它。) 我们现在正在尝试实现这一目标的最佳方式。 到目前为止,我们已经从文档中提取了链接,并在文档中添加了一个l

我们为HTML文档编制索引,其中可能包含指向其他文档的链接。我们使用的是elasticsearch,对于大多数关键词搜索来说都非常流畅,这非常好

现在,我们正在添加更复杂的搜索,类似于Google
站点:
链接:
搜索:基本上我们想要检索指向EIHR特定URL甚至域的文档。(如果文档A有到
http://a.site.tld/path/
,搜索
链接:http://a.site.tld
应该会产生它。)

我们现在正在尝试实现这一目标的最佳方式。 到目前为止,我们已经从文档中提取了链接,并在文档中添加了一个
links
字段。我们将
链接设置为不进行分析。然后,我们可以进行匹配准确url
链接的搜索:http://a.site.tld/path/
但是当然
链接:http://a.site.tld
不会产生任何结果

我们最初的想法是创建一个新字段
linkedDomains
,该字段的工作原理类似于。。。但可能存在更好的解决方案?

您可以尝试以下方法:

定义映射,如下所示:

PUT /link-demo
{
  "settings": {
    "analysis": {
      "analyzer": {
        "path-analyzer": {
          "type": "custom",
          "tokenizer": "path_hierarchy"
        }
      }
    }
  },
  "mappings": {
    "doc": {      
      "properties": {
        "link": {
          "type": "string",
          "index_analyzer": "path-analyzer"          
        }
      }
    }
  }
}
索引文档:

POST /link-demo/doc
{
    link: "http://a.site.tld/path/"
}
以下术语查询返回索引文档:

POST /link-demo/_search?pretty
{
    "query": {
        "term": {
           "link": {
              "value": "http://a.site.tld"
           }
        }
    }
}
要了解如何编制索引,请执行以下操作:

GET link-demo/_analyze?analyzer=path-analyzer&text="http://a.site.tld/path"&pretty
显示以下内容:

{
  "tokens" : [ {
    "token" : "\"http:",
    "start_offset" : 0,
    "end_offset" : 6,
    "type" : "word",
    "position" : 1
  }, {
    "token" : "\"http:/",
    "start_offset" : 0,
    "end_offset" : 7,
    "type" : "word",
    "position" : 1
  }, {
    "token" : "\"http://a.site.tld",
    "start_offset" : 0,
    "end_offset" : 18,
    "type" : "word",
    "position" : 1
  }, {
    "token" : "\"http://a.site.tld/path\"",
    "start_offset" : 0,
    "end_offset" : 24,
    "type" : "word",
    "position" : 1
  } ]
}