Search query using reverse index mixed with other indexes

This also can be done with WIDE_TABLE type only. Therefore to allow reverse index / indexing in the table, we need to create or open table like following:

table_env tenv;
tenv.set_table_type(WIDE_TABLE);
tenv.set_rev_idx(true);
bangdb_table *tbl = bdb->getTable("mywidetable", &tenv);

Now taking the same document as above, let's say we would like to reverse index the content of the field "fav_quote".

Then we would like to add following during put

const char *rev_idx = "{"_rev_idx_all":0, "_rev_idx_key_list":["fav_quote"]}";
//note that _rev_idx_all if set 1 then it will reverse index all the fields in the doc.//Also _rev_idx_key_list is not required in that condition
tbl->put_doc(doc, NULL, rev_idx, INSERT_UNIQUE);

Now to scan for query like above but will add reverse index condition

const char *query = {
    "query":[
       {
          "key":"name",
          "cmp_op":4,
          "val":"sachin"
       },
       {
          "joinop":0
       },
       {
          "key":"address.city",
          "cmp_op":4,
          "val":"Bangalore"
       },
       {
          "joinop":0
       },
       {
          "match_words":"wall, bridge",
          "joinop":0,
          "field":"fav_quote"
       }
    ]
 };
 // now call the scan same way to get the data
 

We could also put normal text (not JSON doc) and scan using put_text and scan_text. In case of put_text(), db will reverse index the input text.

For scan, simply create a list of all the tokens for search in a char*[] and then call scan_text().