Search Refiners


(Yogesh Shetty) #1

I am developing complex search refiner and kind of stuck in identifying best solution.

I am sharing sample trade model that contains few nested object - Custodians, Brokers (both are marked as nested in type mapping)

           "id": "0085c585-3cb4-469c-8357-08e3a31cee91",
           "version": 1,
           "tradedate": "",
           "quantity": "",
           "price":"",
           "custodians": [
                         {
                            "name": "CUST1",
                            "desc": "Custodian 1",
                         },
                         {
                            "name": "CUST2",
                            "desc": "Custodian 2",
                         },
                       ]
           "brokers": [
                         {
                            "id": "1",
                            "name": "BROK1",
                            "desc": "Broker 1",
                         },
                         {
                            "id": "2",
                            "name": "BROK2",
                            "desc": "Broker 2",
                         },
                       ]

In my web page, i have 3 refiners Trades, Custodians, Brokers and google like search bar. In search bar user can enter free form text such as BROK1, and when user clicks on particular refiner hyperlink then information about that data model containing text BROK1 should reflect in the grid. So in this case, when user clicks on
Custodians then no records should appear. The below query will retrieve documents at parent level, is there any way to perform similar _all query at nested document level.

GET trading/trades/_search
{
"query" : {
"flt" : {
"fields" : [ "_all" ],
"like_text" : "BROK1",
"max_query_terms" : 12
}
},
"highlight" : {
"fields" : {
"*" : {}
}
}
}

Additionally, it is possible for highight to fetch some additional fields along with highlighted fields, for instance in above case it will fetch following results in
highlight section

"brokers.name":BROK1

but if I get the id along with that, then it will help me to build my refiners.

The other challenge I have is along with freeform text BROK1, user can also enter filter condition similar to SQL where - such as TradeDate = "" and Custodian = CUST1so that is why above data model is required to allow me to do complex AND join.

Thanks in advance for your help.


(system) #2