简体   繁体   English

如何使用ArangoJS(ArangoDB)为NodeJS应用实现类似于搜索的功能

[英]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.

相关问题 我如何实现 NodeJS 的“你的意思是”功能? - How do I implement NodeJS “Did you mean” feature? 使用arangojs和aqlQuery在ArangoDb中将集合名称用作变量时出错 - Error when using collection names as variables in ArangoDb with arangojs and aqlQuery 如何在 nodejs 中执行此异步功能 - How can I do this asyn feature in nodejs 如何使用Elasticsearch NPM在Node.js中实现ElasticSearch脚本 - How do i implement elasticsearch scripts in nodejs using elasticsearch npm 如何有效地在 MEAN 网络应用程序上实现类似功能? - How to implement a like feature on a MEAN web app efficiently? 我如何使用keycloak在NodeJs中实现注销功能 - How can i implement logout feature in NodeJs with keycloak 在ArangoJS 3.x中使用NodeJs样式函数回调 - Using NodeJs Style function callbacks with ArangoJS 3.x 如何设置 mongoDB 的新 CSFLE 功能,使用 nodejs 进行显式加密隐式解密? - How do I set up mongoDB's new CSFLE feature, with explicit encryption implicit decryption using nodejs? 如何使用Node.js在Redis缓存中创建LIKE运算符搜索? - How to create LIKE operator search in Redis cache using nodejs? 我如何在 NodeJS 中编写一个 CLI 应用程序来清除终端然后恢复它 - How do I write a CLI app in NodeJS which clears the terminal and then restores it afterwards
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM