简体   繁体   中英

How Do I Implement Search Like Feature For NodeJS App Which Using ArangoJS(ArangoDB)

{ sno : "1", name: "abc", comment1: "dd cdt djdhj", myComment: "adt dtt cdt abc" }

{ sno : "2", name: "adc", comment1: "dd ddt djdhj", myComment: "adt t cdt abc" }

{ sno : "3", name: "ab", comment1: "dd cdt djdhj", myComment: "cdt abc" }

{ sno : "4", name: "ddt", comment1: "dd cdt djdhj", myComment: "adt dtt" }

I have data stored like the above shown in collection named users in ArangoDB

If i search for query "dtt" it should return all documents which contains query str ..

How To Do This Using ArangoJS (Just as simple search feature in an NodeJS Application)

I want to know is there any built-in feature is available in ArangoJS just like MongoDB's find() method.

For no nested structure in the json document this can be done.

for (key in jsonDoc){
    var value = jsonDoc[key];
    if (key.toString().indexOf(searchstr) != -1  || value.toString().indexOf(searchstr) != -1){
        FOUND A MATCH
    }

If there is a nested structure in the json , you will have to use a traversal method. Search for "Traversing Json" and implement the same concept as above

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM