Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

对于嵌套的Object对象,查询语句需要用下划线'_'代替句号'.'才能查询到 #404

Closed
Huaixinww opened this issue Dec 27, 2023 · 1 comment

Comments

@Huaixinww
Copy link
Collaborator

Huaixinww commented Dec 27, 2023

由于fed生成schema和写入doc时,将数据结构打平时会用下划线' _ '代替es的句号' . ',
所以对于嵌套的Object对象,fed内部实际上是使用下划线' _ '而不是es所使用的句号' . '来划分层次的,
导致使用查询语句时,需要用' _ '来查询子字段,而不是es的' . ',
例子如下:

#创建索引
PUT test_index3
{
  "settings": {
    "index.engine": "havenask",
    "number_of_shards": 1, 
    "number_of_replicas": 0
  },
  "mappings": {
    "properties": {
      "foo":{
        "type":"keyword"
      },
      "user": { 
        "properties": {
          "name": { 
            "type": "keyword"
          },
          "age": { 
            "type": "integer"
          },
          "image":{
            "type":"vector",
            "dims":"2",
            "similarity":"l2_norm"
          }
        }
      }
    }
  }
}

#写入数据
PUT /test_index3/_doc/1
{
  "foo":"test1",
  "user": {
    "name": "Alice",
    "age": "30",
    "image": [0.5, 0.6]
  }
}

PUT /test_index3/_doc/2
{
  "foo":"test2",
  "user": {
    "name": "Bob",
    "age": "25",
    "image": [0.4, 0.7]
  }
}

PUT /test_index3/_doc/3
{
  "foo":"test3",
  "user": {
    "name": "Charlie",
    "age": 35,
    "image": [0.3, 0.8]
  }
}

#使用这个查询可以查询到对于的数据
GET /test_index3/_search
{
  "query": {
    "match": {
      "user_age": 35
    }
  }
}

#使用这个查询无法查到数据
GET /test_index3/_search
{
  "query": {
    "match": {
      "user.age": 35
    }
  }
}
@Huaixinww
Copy link
Collaborator Author

Huaixinww commented Jan 5, 2024

fixed by:#411

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant