Elasticsearch-搜索组下的项目

时间:2018-10-16 03:46:12

标签: elasticsearch search indexing full-text-search

我想在“虚拟分区”中搜索项目,这些项目是分开的或属于组标识符,

例如:我的系统上有多个组织,每个组织都有其产品(资产),我希望允许每个组织成员搜索其组织下的产品,搜索结果仅包括属于他的组织的项目,而没有来自其他组织...

类似 SELECT * FROM assets WHERE org_id = 'GUID' AND (name LIKE '%QUERY%' OR category LIKE '%QUERY%'OR tag LIKE '%QUERY%')

这是索引设置:

PUT assets {
  "settings": {
    "analysis": {
       "filter": {
          "nGram_filter": {
          "type": "ngram",
          "min_gram": 2,
          "max_gram": 20,
          "token_chars": [
            "letter",
            "digit",
            "punctuation",
            "symbol"
          ]
        }
      },
      "analyzer": {
        "nGram_analyzer": {
          "type": "custom",
          "tokenizer": "whitespace",
          "filter": [
            "lowercase",
            "asciifolding",
            "nGram_filter"
          ]
        },
        "whitespace_analyzer": {
          "type": "custom",
          "tokenizer": "whitespace",
          "filter": [
            "lowercase",
            "asciifolding"
          ]
        }
      }
    }
  },
  "mappings": {
    "asset": {
      "properties": {
        "name": {
          "type": "text",
          "analyzer": "nGram_analyzer",
          "search_analyzer": "whitespace_analyzer"
        },
        "categories": {
          "type": "text",
          "analyzer": "nGram_analyzer",
          "search_analyzer": "whitespace_analyzer"
        },
        "genres": {
          "type": "text",
          "analyzer": "nGram_analyzer",
          "search_analyzer": "whitespace_analyzer"
        },
        "tags": {
          "type": "text",
          "analyzer": "nGram_analyzer",
          "search_analyzer": "whitespace_analyzer"
        }
      }
    }
  }
}

我假设org_id的索引设置不应包含analysisanalyzer,因为我想按精确值进行过滤,但是我确实想将诸如位图索引之类的索引设置为创建一些由org_id分开的“虚拟分区”子组。

然后,org_id应该如何出现在mappings段中?

0 个答案:

没有答案