Retrieving Documents @elastic/app-search-node

Hi i got problem with this npm,

When i want to retrieve documents. My Code
image

I got this :
image

Package doesnt send any Body and request was empty and result 400 bad request
image

Seem Request package doesn't add JSON or Params

Hi @Jonathan_Gautier,

What version are you running? npm list @elastic/app-search-node

Are you using self managed app search or saas?

Can you paste a snippet of code rather than a screenshot?

Jason

@JasonStoltz
self managed app search

const {hostIdentifier, searchKey, endpointBase, engineName} = getConfig();
const AppSearchClient = require('@elastic/app-search-node');
const baseUrlFn = () => endpointBase + '/api/as/v1/';
const clientDirect = new AppSearchClient(undefined, searchKey, baseUrlFn);

clientDirect
  .getDocuments(engineName, ["park_zion", "does_not_exist"])
  .then(response => console.log(response))
  .catch(error => console.log(error.errorMessages))

dependencies:

"dependencies": {
"@elastic/app-search-node": "^7.5.0",
"@elastic/react-search-ui": "^1.1.0",
"@elastic/react-search-ui-views": "^1.3.2",
"@elastic/search-ui-app-search-connector": "^1.1.0",
"@material-ui/core": "^4.9.0",
"dummyjs": "^1.1.7",
"moment": "^2.24.0",S
"mongodb-stitch-browser-sdk": "^4.8.0",
"namor": "^2.0.2",
"prop-types": "^15.6.2",
"react": "^16.8.1",
"react-dom": "^16.8.1",
"react-form": "^4.0.1",
"react-masonry-css": "^1.0.14",
"react-modal": "^3.11.1",
"react-redux": "^7.1.3",
"react-router-dom": "^5.1.2",
"react-scripts": "3.1.1",
"react-table": "^7.0.0-rc.15",
"redux": "^4.0.5",
"request": "^2.88.0"

},

I couldn't reproduce this:

var AppSearchClient = require("@elastic/app-search-node");

var apiKey = "private-u7sgy8ekgbhoeb8u3pgrot3g";
var baseUrlFn = () => "http://localhost:3002/api/as/v1/";
var engineName = "my-search-engine";
var client = new AppSearchClient(undefined, apiKey, baseUrlFn);

client
  .getDocuments(engineName, ["park_saguaro", "does_not_exist"])
  .then(console.log);

/*
> [ { title: 'Saguaro',
    description:
     'Split into the separate Rincon Mountain and Tucson Mountain districts, this park is evidence that the dry Sonoran Desert is still home to a great variety of life spanning six biotic communities. Beyond the namesake giant saguaro cacti, there are barrel cacti, chollas, and prickly pears, as well as lesser long-nosed bats, spotted owls, and javelinas.',
    nps_link: 'https://www.nps.gov/sagu/index.htm',
    states: [ 'Arizona' ],
    visitors: '820426',
    world_heritage_site: 'false',
    location: '32.25,-110.5',
    acres: '91715.72',
    square_km: '371.2',
    date_established: '1994-10-14T05:00:00Z',
    id: 'park_saguaro' },
  null ]
*/

Quick thought, you're not trying to use the node client from a browser are you?

FYI, you'd want to use the javascript client in the browser, not the node client. The javascript client is already a dependency of the search-ui-app-search-connector:

→npm list @elastic/app-search-javascript
/Users/jasonstoltzfus/workspace/temp/test-node-client
└─┬ @elastic/search-ui-app-search-connector@1.3.2
  └── @elastic/app-search-javascript@7.5.0

This is for React project, i can use @elastic/app-search-javascript, but how to get one document ? Thanks

Just do a search and filter on the "id" filter.