[英]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:“ 1”,名称:“ abc”,comment1:“ dd cdt djdhj”,myComment:“ adt dtt cdt abc”}
{ sno : "2", name: "adc", comment1: "dd ddt djdhj", myComment: "adt t cdt abc" } {sno:“ 2”,名称:“ adc”,comment1:“ dd ddt djdhj”,myComment:“ adt t cdt abc”}
{ sno : "3", name: "ab", comment1: "dd cdt djdhj", myComment: "cdt abc" } {sno:“ 3”,名称:“ ab”,comment1:“ dd cdt djdhj”,myComment:“ cdt abc”}
{ sno : "4", name: "ddt", comment1: "dd cdt djdhj", myComment: "adt dtt" } {sno:“ 4”,名称:“ ddt”,comment1:“ dd cdt djdhj”,myComment:“ adt dtt”}
I have data stored like the above shown in collection named users in ArangoDB 我在ArangoDB中以命名用户的集合形式存储了如上所示的数据
If i search for query "dtt" it should return all documents which contains query str .. 如果我搜索查询“ dtt”,它应该返回包含查询str ..的所有文档。
How To Do This Using ArangoJS (Just as simple search feature in an NodeJS Application) 如何使用ArangoJS做到这一点 (就像NodeJS应用程序中的简单搜索功能一样)
I want to know is there any built-in feature is available in ArangoJS just like MongoDB's find() method. 我想知道ArangoJS是否有任何内置功能,就像MongoDB的find()方法一样。
For no nested structure in the json document this can be done. 对于json文档中没有嵌套结构的情况,可以这样做。
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. 如果json中存在嵌套结构,则必须使用遍历方法。 Search for "Traversing Json" and implement the same concept as above
搜索“ Traversing Json”并实现与上述相同的概念
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.