@lahrm (lahrm) posted a new topic, subject "Error when using the delete-by-query plugin for Elasticsearch on Bitnami". It read:

   Hi,
    
    I am working on Firebase along with Elasticsearch and I am getting the error below when I try to delete an index from Elasticsearch using delete-by-query. The index creation works well using a cloud function so the connection should be ok.
    
    Is deleteByQuery somehow not supported by Elasticsearch on bitnami?
    
    Documentation about the deletebyquery: npmjs.com
    
    **Error:**
    [code] 
        Trace: { Error: Incorrect HTTP method for uri [/products/_query] and method [DELETE], allowed: [POST]
            at respond (/user_code/node_modules/elasticsearch/src/lib/transport.js:307:15)
            at checkRespForFailure (/user_code/node_modules/elasticsearch/src/lib/transport.js:266:7)
            at HttpConnector.<anonymous> (/user_code/node_modules/elasticsearch/src/lib/connectors/http.js:159:7)
            at IncomingMessage.bound (/user_code/node_modules/elasticsearch/node_modules/lodash/dist/lodash.js:729:21)
            at emitNone (events.js:91:20)
            at IncomingMessage.emit (events.js:185:7)
            at endReadableNT (_stream_readable.js:974:12)
            at _combinedTickCallback (internal/process/next_tick.js:80:11)
            at process._tickDomainCallback (internal/process/next_tick.js:128:9)
          status: 405,
          displayName: 'MethodNotAllowed',
        
    [/code]
    
    **Code executed:**
    [code] 
        const apiVersion = '6.x';
        const esClient = new elasticsearch.Client({
        	host: 'http://xx.xxx.xxx.xx//elasticsearch',
        	protocol: 'http',
        	apiVersion,
        	httpAuth:'user:xxxxxxxxxxxxx',
        	plugins: [ deleteByQuery ],
        	log: 'error'
        });
        return esClient.deleteByQuery({
        index: 'products',
          body: {
        	query: {
        		term: { product_name: 'test1' }
        	}
          }
        }, function (error, response) {
          console.trace(error);
        });
    [/code]

So @dadoonet (David Pilato) replied

    I don't know but I thought it is worth noticing that delete by query moved from a plugin to an actual feature. May be the client you are using has not been updated?

Then @lahrm (lahrm) said

    I spent several days on this issue and you just solved it with your very helpful answer.
    
    Thanks a lot

So @system (system) replied

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


{'source': 'discourse', 'url': 'https://discuss.elastic.co/t/error-when-using-the-delete-by-query-plugin-for-elasticsearch-on-bitnami/129349', 'title': 'Error when using the delete-by-query plugin for Elasticsearch on Bitnami', 'views': 350, 'has_accepted_answer': True, 'word_count': 277, 'like_count': 0, 'reply_count': 1, 'participant_count': 2, 'posts': 4, 'tags': '', 'author': '@lahrm (lahrm)', 'participants': '@lahrm (lahrm), @dadoonet (David Pilato), @system (system)', 'image_url': [None], 'created_at': '2018-04-24T16:13:08.006Z', 'last_posted_at': '2018-05-23T08:43:22.308Z'}