Skip to content

TypeError: Cannot convert undefined or null to object #186

@DarrenMa

Description

@DarrenMa

Hi suhas,

Is it possible to refactor some of the query building logic into modules? I want to separate parts of the process into nodejs modules. but when I do this I get the title error.

I posted the full question here

Perhaps it's not possible?

Like this:

import esb from 'elastic-builder';
import { ToElasticFilter } from 'filtermodule';
import { ToElasticSort } from 'sortmodule';

const run = () => {

  // add any customers filters here
  const boolBody = ToElasticFilter(); // esb.boolQuery().must(esb.regexpQuery('catch_all', `.*test.*`).flags('NONE'));

  // apply the sorting here
  const s = ToElasticSort(); // esb.sort('catch_all', 'asc').missing('_last').mode('max').unmappedType('keyword');

  // build the base query here
  const body = esb.requestBodySearch().query(boolBody).sort(s);

  console.log(JSON.stringify(body.toJSON(), null, 2));

};

run();

Thank you for your time and work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions