Thursday 4 May 2017

How to insert variable name into elasticsearch query in elasticsearch.js

I get replies for my query and my code looks like this.

client.search({                                                                                                                                                                                                      
   index: 'sys',                                                                                                                                                                                                      
  body: {                                                                                                                                                                                                            
       size:'10',                                                                                                                                                                                                       
       query: {                                                                                                                                                                                                         
         match:{                                                                                                                                                                                                    
                  syscall_name:'SyS_read'
                }                                                                                                                                                                                                    
       }                                                                                                                                                                                                            
     }                                                                                                                                                                                                                  
},function (error,response) {                                                                                                                                                                                        
if (error) {                                                                                                                                                                                                     
        console.trace('Search query failed');                                                                                                                                                                    
      }                                                                                                                                                                                                          
else {                                                                                                                                                                                                           
        console.log('All is well');                                                                                                                                                                              
        d=response;                                                                                                                                                                 
        showdocs(d)                                                                                                                                                                                              
      }                                                                                                                                                                                                          
});                                                                                                                                                                                                              
}

I want to user to input a syscall name and that variable should be searched for in the query. Is this possible?



via Vintux

No comments:

Post a Comment