Complex object indexed by FTS

@abhinav ,

If I have a document who has a structure similar to this:

"type": "bar",
"a_r": {
    "foo: {
      "foo1": {
        "foo2": {
          "10": {
            "hr": 236,
            "hrt": 1612627200
          },
          "12": {
            "hr": 395,
            "hrt": 1612627200
          }
        }
      }
    },
    "foo3": {
      "foo4": {
        "foo5": {
          "10": {
            "hr": 369,
            "hrt": 1610683200
          }
        }
      }
    }
  }

I am not interested in search into this object, but just retrieve it as a part of the result object

Do you think it is possible to index the root, in this case, the “a_r” so that when I do a query on type = “bar” to get the a_r data?

I tried to index the a_r data as text, number, object (dynamic), I stored, etc. But it seems is not returned on any query, so I am not sure it is indexed or the query doesn’t know how to retrieve it

Yes, it is possible.

  • You’ll need to set “a_r” as a dynamic child mapping first - that’s correct.
  • Next go to the “Advanced” section towards the end of the “Create Index” page and enabled “Store Dynamic Fields”.
  • Now your query should looks like this …
{"query": {"match": "bar", "field":"type"}, "fields":["*"]}

This will emit all the field values that you’ve stored. For your example …

        "a_r.foo.foo1.foo2.10.hr": 236,
        "a_r.foo.foo1.foo2.10.hrt": 1612627200,
        "a_r.foo.foo1.foo2.12.hr": 395,
        "a_r.foo.foo1.foo2.12.hrt": 1612627200,
        "a_r.foo3.foo4.foo5.10.hr": 369,
        "a_r.foo3.foo4.foo5.10.hrt": 1610683200
1 Like

oh, thank you!!!

that’s was missing

image