# Querying elasticsearch with javascript

**URL:** <https://discuss.elastic.co/t/querying-elasticsearch-with-javascript/96369>\
**Category:** Elasticsearch\
**Created:** [August 9, 2017, 3:49am UTC](https://discuss.elastic.co/t/querying-elasticsearch-with-javascript/96369 "2017-08-09T03:49:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MRamzan](https://avatars.discourse-cdn.com/v4/letter/m/eada6e/32.png) [@MRamzan](https://discuss.elastic.co/u/MRamzan)\
**Post date:** [August 9, 2017, 3:49am UTC](https://discuss.elastic.co/t/querying-elasticsearch-with-javascript/96369/1 "2017-08-09T03:49:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 6, 2017, 3:49am UTC](https://discuss.elastic.co/t/querying-elasticsearch-with-javascript/96369/2 "2017-09-06T03:49:30Z")

</div>

Closed on September 6, 2017, 3:49am UTC

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