- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的 copy_to 可以正常工作以进行精确匹配,但我无法通过部分匹配正确设置它。以下是我的映射/设置和查询以及预期和实际结果。
设置:
{
"test": {
"settings": {
"index": {
"analysis": {
"filter": {
"ngram_filter": {
"type": "edge_ngram",
"min_gram": "1",
"max_gram": "15"
}
},
"analyzer": {
"ngram_analyzer": {
"filter": [
"lowercase",
"ngram_filter"
],
"type": "custom",
"tokenizer": "standard"
}
}
},
"number_of_shards": "1",
"number_of_replicas": "1",
}
}
}
}
映射:
POST /test/_mapping/name
{
"name": {
"properties": {
"vital": {
"properties": {
"first": {
"type": "string",
"copy_to": "full_name",
"term_vector": "yes",
"analyzer": "ngram_analyzer",
"search_analyzer": "standard"
},
"last": {
"type": "string",
"copy_to": "full_name",
"term_vector": "yes",
"analyzer": "ngram_analyzer",
"search_analyzer": "standard"
},
"full_name": {
"type": "string",
"term_vector": "yes",
"analyzer": "ngram_analyzer",
"search_analyzer": "standard"
}
}
}
}
}
}
发布:
POST /test/name
{
"vital": {
"first": "Tom",
"last": "Doe"
}
}
现在当我进行搜索时...
GET /test/name/_search
{
"query": {
"match": {
"full_name": {
"query": "Tom Doe",
"operator": "and"
}
}
}
}
...我得到了结果!! Hurrraaaay,但如果我进行搜索......
GET /test/name/_search
{
"query": {
"match": {
"full_name": {
"query": "Tom Do",
"operator": "and"
}
}
}
}
... 我没有得到任何结果 :( 我希望部分匹配也适用于 full_name。作为另一个原因,我成功地能够对名字和姓氏进行部分匹配。只是 full_name 不起作用. 我该怎么做?
最佳答案
你在映射中有一个小错误,你需要将名字和姓氏复制到 vital.full_name
字段中,而不仅仅是 full_name
,否则会创建一个名为 full_name
的新字符串字段,在映射的顶层带有标准分析器(如果运行 GET test
,您将在映射中看到该新字段):
POST /test/_mapping/name
{
"name": {
"properties": {
"vital": {
"properties": {
"first": {
"type": "string",
"copy_to": "vital.full_name", <--- fix this
"term_vector": "yes",
"analyzer": "ngram_analyzer",
"search_analyzer": "standard"
},
"last": {
"type": "string",
"copy_to": "vital.full_name", <--- fix this
"term_vector": "yes",
"analyzer": "ngram_analyzer",
"search_analyzer": "standard"
},
"full_name": {
"type": "string",
"term_vector": "yes",
"analyzer": "ngram_analyzer",
"search_analyzer": "standard"
}
}
}
}
}
}
然后像这样修正你的查询:
POST /test/name/_search
{
"query": {
"match": {
"vital.full_name": { <-- fix this
"query": "Tom Doe",
"operator": "and"
}
}
}
}
POST /test/name/_search
{
"query": {
"match": {
"vital.full_name": { <-- fix this
"query": "Tom Do",
"operator": "and"
}
}
}
}
两者都会如您所愿地工作。
关于search - Elasticsearch | copy_to 部分搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41817487/
(我正在使用 Elasticsearch 1.5.2 的全新副本执行此操作) 我已经定义了一个自定义分析器并且它正在工作: curl -XPUT 127.0.0.1:9200/test -d '{
为什么带有“copy_to”选项的字段不返回任何术语向量数据?例如,我正在运行以下内容: GET my_index/my_type/1/_termvectors?fields=full_name
是否可以在嵌套字段中使用 copy_to : 这是我的映射的摘录: day: { type: nested properties: { weight: {
我有一个包含两个字符串字段的索引映射,field1 和 field2,它们都被声明为 copy_to 到另一个名为 all_fields 的字段。 all_fields 被索引为“not_analyz
我正在为dot.net使用Elasticsearch 6 Nest 我使用_all字段来搜索所有索引,但是现在不推荐使用,所以我需要一个新的解决方案 我发现copy_to选项足够好。 我的问题是:出于
我们有一个使用copy_to(自定义_all)的elasticsearch映射。它仅用于查询,不存储。我们使用“analyzer”:“german”分析原始的file_content_de。我们是否还
我正在尝试将 Elastic Search 5.6 中的主标题字段复制到另一个字段:index:false,因此我可以使用该字段来匹配准确的值。 但是。重新索引后,使用_source:["exact_
我正在尝试将本地数据帧从 R 复制到我的 db2 数据库。我有权写入表,并且我已验证连接正常。 我正在使用: copy_to(connection, data.frame, name = my_tab
我正在尝试将本地数据帧从 R 复制到我的 db2 数据库。我有权写入表,并且我已验证连接正常。 我正在使用: copy_to(connection, data.frame, name = my_tab
我的 copy_to 可以正常工作以进行精确匹配,但我无法通过部分匹配正确设置它。以下是我的映射/设置和查询以及预期和实际结果。 设置: { "test": { "settings"
也许我遗漏了一些简单的东西,但仍然无法弄清楚以下内容: 从 ES 6.x 开始,_all 字段已弃用,建议使用 copy_to 指令 (https://www.elastic.co/guide/en/
我正在使用 Sparklyr 库从 R 读取数据并将数据写入 HDFS。读取数据按预期工作,但写入会出现问题。 为了能够使用 spark_write_csv 函数,我需要将我的 R data.fram
根据 x86 和 ppc 上的 linux 设计,4g 虚拟地址空间被划分为 3:1。 用户虚拟地址直到 3g。 现在,如果用户应用程序执行 ioctl 传递指向缓冲区的指针,内核模块可以直接执行 m
我想使用 dplyr 中的 copy_to() 创建一个新表。索引可以很容易地指定,但我没有看到指定主键的语法。推荐的方法是首先简单地创建表,然后使用 copy_to() 将数据复制到其中作为第二步,
我很困惑! 我有一个简单的 chardev 和用户空间应用程序,它通过 ioctl 向 chardev 发送/接收缓冲区。 当我通过malloc(在堆上)分配缓冲区(在用户空间中)时,有时在free(
ElasticSearch 能够将值复制到其他字段(在索引时),使您能够像搜索一个字段一样搜索多个字段 ( Core Types: copy_to )。 但是,似乎没有任何方法可以指定复制这些值的顺序
我正在尝试为我正在编写的包创建一个小型培训数据库。我正在使用以下代码创建数据库: library(tidyverse) library(DBI) dat % tbl("client_list") 谁能
我在Elasticsearch(v 1.5.0)中有一个索引,该索引具有如下所示的映射: { "storedash": { "mappings": { "outofstock"
我有下面的代码,它使用一个使用 Sparklyr 调用 spark SQL API 的包装函数对数据集执行 SQL 转换。然后,我使用“invoke("createOrReplaceTempView"
我正在使用 Elasticsearch v2.3.0。假设我有一个带有映射的索引: { "mappings": { "post": { "dynamic": false, "_so
我是一名优秀的程序员,十分优秀!