1

运行命令:

curl -XGET http://127.0.0.1:9200/30556/_search -d '{
    "query": {
        "constant_score" : {
            "filter" : {
                "term" : { "portal_type" : "Folder"}
            }
        }
    }
}'

产生 0 个结果。输出是:

{"took":1,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}

如果事实上,我无法得到任何查询来产生结果。

但是,当我使用 head 插件运行相同的查询时,它工作正常。

我在 Mac OS X 上使用 elasticsearch 0.20.2。我正在使用以下命令启动弹性搜索:

bin/elasticsearch -f

我有什么明显的遗漏吗?好像我有正确的语法,我没有得到任何错误。

映射:

{
  "30556": {
    "portal_catalog": {
      "properties": {
        "CreationDate": {
          "type": "date",
          "format": "dateOptionalTime"
        },
        "Creator": {
          "type": "string"
        },
        "Date": {
          "type": "date",
          "format": "dateOptionalTime"
        },
        "Description": {
          "type": "string"
        },
        "ModificationDate": {
          "type": "date",
          "format": "dateOptionalTime"
        },
        "SearchableText": {
          "type": "string"
        },
        "Title": {
          "type": "string"
        },
        "Type": {
          "type": "string"
        },
        "UID": {
          "type": "string"
        },
        "allowedRolesAndUsers": {
          "type": "string"
        },
        "created": {
          "type": "date",
          "format": "dateOptionalTime"
        },
        "effective": {
          "type": "date",
          "format": "dateOptionalTime"
        },
        "effectiveRange": {
          "dynamic": "true",
          "properties": {
            "effectiveRange1": {
              "type": "date",
              "format": "dateOptionalTime"
            },
            "effectiveRange2": {
              "type": "date",
              "format": "dateOptionalTime"
            }
          }
        },
        "exclude_from_nav": {
          "type": "boolean"
        },
        "expires": {
          "type": "date",
          "format": "dateOptionalTime"
        },
        "getId": {
          "type": "string"
        },
        "getObjPositionInParent": {
          "type": "long"
        },
        "getObjSize": {
          "type": "string"
        },
        "id": {
          "type": "string"
        },
        "is_default_page": {
          "type": "boolean"
        },
        "is_folderish": {
          "type": "boolean"
        },
        "listCreators": {
          "type": "string"
        },
        "meta_type": {
          "type": "string"
        },
        "modified": {
          "type": "date",
          "format": "dateOptionalTime"
        },
        "object_provides": {
          "type": "string"
        },
        "path": {
          "dynamic": "true",
          "properties": {
            "depth": {
              "type": "long"
            },
            "path": {
              "type": "string"
            }
          }
        },
        "portal_type": {
          "type": "string"
        },
        "review_state": {
          "type": "string"
        },
        "sortable_title": {
          "type": "string"
        },
        "total_comments": {
          "type": "long"
        }
      }
    }
  }
}

示例索引文档:

{
        "_index": "30556",
        "_type": "portal_catalog",
        "_id": "30613",
        "_score": 1,
        "_source": {
          "sortable_title": "news",
          "exclude_from_nav": false,
          "meta_type": "ATFolder",
          "Date": "2013-01-14T09:24:56-06:00",
          "CreationDate": "2013-01-14T09:24:56-06:00",
          "path": {
            "depth": 2,
            "path": "/el/news"
          },
          "allowedRolesAndUsers": [
            "Anonymous"
          ],
          "portal_type": "Folder",
          "id": "news",
          "UID": "3116b6c7ec384a9393f238fdde778612",
          "expires": "2499-12-31T00:00:00-06:00",
          "Subject": [],
          "is_folderish": true,
          "is_default_page": false,
          "effectiveRange": {
            "effectiveRange1": "1000-01-01T00:00:00-06:00",
            "effectiveRange2": "2499-12-31T00:00:00-06:00"
          },
          "commentators": [],
          "created": "2013-01-14T09:24:56-06:00",
          "getRawRelatedItems": [],
          "cmf_uid": [],
          "Creator": "admin",
          "end": [],
          "modified": "2013-01-14T09:24:56-06:00",
          "Description": "Site News",
          "ModificationDate": "2013-01-14T09:24:56-06:00",
          "total_comments": 0,
          "in_reply_to": [],
          "getIcon": "",
          "effective": "1000-01-01T00:00:00-06:00",
          "SearchableText": "news  News  Site News ",
          "getObjPositionInParent": 61,
          "object_provides": [
            "collective.syndication.interfaces.ISyndicatable",
            "Products.ATContentTypes.interfaces.folder.IATFolder",
            "Products.CMFCore.interfaces._content.IContentish",
            "z3c.relationfield.interfaces.IHasIncomingRelations",
            "webdav.interfaces.IWriteLock"
          ],
          "last_comment_date": null,
          "review_state": "published",
          "start": [],
          "Type": "Folder",
          "listCreators": [
            "admin"
          ],
          "getId": "news",
          "getObjSize": "1 kB",
          "Title": "News"
        }
4

1 回答 1

4

尝试使用小写的索引名称。

它有效吗?

如果没有,您能否提供您的索引文档和映射(如果有)?

更新:您使用默认分析器,因此您的字段被分解为小写的标记。没有分析 TermFilter 所以它不匹配。

您可以小写您的 TermFilter 或使用已分析的 MatchQuery 或更改您的映射并将字段设置为 not_analyzed。

于 2013-01-17T20:15:10.177 回答