Wild Card Feature on the Field Name in Lucene

34 Views Asked by At

I have a json data which is flatten for the Lucene Document. This json contains array also with each element having an identifier. For Ex :

{
 "data":[
    {
      "id" : 01,
      "name" : "Test1",
      "category":[
         { 
           "id" : "100,
           "type" : "AX1,
         },
         { 
           "id" : "101,
           "type" : "AX2,
         }
      ]
    },
    {
      "id" : 02,
      "name" : "Test1",
      "category":[
         { 
           "id" : "102,
           "type" : "AX1,
         },
         { 
           "id" : "103,
           "type" : "AX3,
         }
      ]
    }
  ]
}

The flatten lucene document is :

-- Document -- : 
  Field : data.id                , Value : 01
  Field : data.id.01.name        , Value : Test1
  Field : data.id.01.category.id          , Value : 100
  Field : data.id.01.category.id.100.type , Value : AX1
  Field : data.id.01.category.id          , Value : 101
  Field : data.id.01.category.id.101.type , Value : AX2

similarly for other entries of the above json data

How can I achieve the objective to have lucene query which can search for all category where type is : AX1 and also to get the id of the matching entry ?

I thought if I write the lucene query in the wild card format i.e. +(data.id. * .category.id. * .type : AX1) this can search on any matching doc. However it doesn't work as probably lucene may not have wild card feature on field name ?

0

There are 0 best solutions below