Querying elasticsearch with javascript


(Ramzan) #1

I am new to elasticsearch. And I have two documents which are JarFileData and ClassData. I have linked those two documents with jarFileId field.

This is the ClassData

{
"_id" : ObjectId("59881021e950041f0c6fa1fa"),
"ClassName" : "core/internal/TrackingEventQueue$TrackingException",
"jarFileId" : "JAR-0001",
"dependencies" : [ 
    {
        "dependedntClass" : "java/lang/RuntimeException",
        "methodSignature" : "<init>"
    }, 
    {
    {
        "dependedntClass" : "java/awt/EventQueue",
        "methodSignature" : "isDispatchThread"
    }, 
    {
        "dependedntClass" : "core/internal/TrackingEventQueue$TrackingException",
        "methodSignature" : "setStackTrace"
    }
]
}

This is JarFileData

{
"_id" : ObjectId("59881021e950041f0c6fa1f7"),
"jarFileName" : "Client.jar",
"jarFileId" : "JAR-0001",
"directory" : "C:\\Projects\\Test\\Application",
"version" : null,
"artifactID" : null,
"groupID" : null
}

I want to give a directory and get all jarFiles in that directory and use it to find the dependent classes in ClassData type for those jarFiles.

This is the function I used in node.js for reteriving jarFileData type for a given directory.

const test = function test() {
let body = {
  size: 20,
  from: 0,
  {
   query: {
     match: {
       directory: 'C:\\Projects\\Test\\Application'
        }
      }
    }
  };
}

I am trying to use the resultset from the above query to query classData type.
I am stuck in this part for a long time and don't know how to do it in elastic-search. Any help would be much appreciated.


(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.