GithubHelp home page GithubHelp logo

elastic / enterprise-search-js Goto Github PK

View Code? Open in Web Editor NEW
19.0 185.0 9.0 281 KB

Official Node.js client for Elastic Enterprise Search, App Search, and Workplace Search.

Home Page: https://www.elastic.co/guide/en/enterprise-search-clients/index.html

License: Apache License 2.0

JavaScript 3.63% TypeScript 89.80% Dockerfile 0.16% Shell 6.41%
elasticsearch elastic client nodejs enterprise-search appsearch app-search elastic-search elastic-enterprise-search elastic-appsearch

enterprise-search-js's Introduction

Elastic Enterprise Search

js-standard-style Build Status. Node CI

Official Node.js and universal clients for Elastic Enterprise Search, App Search, and Workplace Search.

License

This software is licensed under the Apache 2 license.

enterprise-search-js's People

Contributors

delvedor avatar joshmock avatar leemthompo avatar picandocodigo avatar pquentin avatar richkuz avatar sethmlarson avatar tattdcodemonkey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

enterprise-search-js's Issues

app.putSchema() schema param types do not match the documentation

πŸ› Bug Report

The provided typescript types for the schema property in the params object for client.app.putSchema() do not match the example provided in the documentation.

To Reproduce

async function run () {
  const schemaUpdate = await client.app.putSchema(
    {engine_name: 'national-parks',
    schema: {date_established: 'date'}})
  if (schemaUpdate.errors) {
    console.log(schemaUpdate)
    process.exit(1)
  }
  console.log(schemaUpdate)}

run().catch(console.error)

Expected behavior

The provided type for the param property schema is as follows:

schema?:  {
        [k: string]: {
            [k: string]: unknown;
        };
    };

This requires nested object structure while the documentation demonstrates a flat object. I assume this typing is off, but if not, I would expect the example to reflect why the schema object shape is something other than a
Record<string,unknown>

  • node version: 18.14.2
  • @elastic/enterprise-search version: 8.6.0
  • os: Mac
  • typescript version: 4.7.4

Add typescript generics for search results response

πŸš€ Feature Proposal

Implement the same type of TypeScript generics for search responses as can be seen in the elastic javascript client, where it's possible to define the results type of the response.

Motivation

At the moment, the type definition of the results part of a search response is defined as results: Array<{}>;. Comparing with the elasticsearch js client, which we sadly doesn't seem to be able to use since we use the enterprise app search. The way they have solved this looks like a better approach in my opinion.

They seem to be using the Elasticsearch specification repo for this, at least according to their docs.

For context, we are utilizing the node js client in our project.

Example

interface Document {
  character: string
  quote: string
}

const result= await client.search<Document>({
    index: 'game-of-thrones',
    query: {
      match: { quote: 'winter' }
    }
  })

The above would return the same response type as is currently implemented, but also with the results array typed with the Document interface.

Compile issues using ES Modules

πŸ› Bug Report

There appears to be a bug that causes type errors and compilation failure if the @elastic/enterprise-search module is used with ES Modules.

To Reproduce

Steps to reproduce the behavior:

Note that in the tsconfig.json file the property "skipLibCheck": false must be set (or the default generated setting of true must be commented out).

Your README example uses require and will work fine.

const { Client } = require('@elastic/enterprise-search')

However, the following will not compile:

import { Client } from '@elastic/enterprise-search';

Using the above will fail with type errors, such as:

node_modules/@elastic/enterprise-search/index.d.ts:22:49 - error TS2307: Cannot find module './lib/types' or its corresponding type declarations.

Expected behavior

A clean compilation without errors.

Your Environment

  • node version: 14, 16, 18
  • @elastic/enterprise-search version: ^8.1.0-beta.1
  • os: Windows, Linux

No resultSuggestions API ?

πŸ’¬ Questions and Help

On the doc, I see the following sections:

  1. Guides > Query Suggestions Guide (https://www.elastic.co/guide/en/app-search/current/query-suggestions-guide.html)
  2. Guides > Result Suggestions Guide (https://www.elastic.co/guide/en/app-search/current/result-suggestions-guide.html)

But in the API section, only the query suggestions are described. Nothing for the result suggestions API?

Also nothing here: https://www.elastic.co/guide/en/enterprise-search-clients/enterprise-search-node/8.8/index.html

And client.querySuggestions() exists but not client.resultSuggestions().

search_explain is unusable with a 8.7 deployment

πŸ› Bug Report

We can't use app.search_explain with our new deployment (8.7.0).

To Reproduce

const explanation = await esClient.app.search_explain({
    engine_name,
    body: {
      query: '',
      page: {
        size: 0
      }
    }
  });

Expected behavior

I should receive a response in line with what's described in https://www.elastic.co/guide/en/app-search/8.7/search-explain.html#search-explain-api-examples

Instead, I'm getting :

ResponseError: {"errors":"Routing Error. The path you have requested is invalid."}

Our older deployments (of version 8.5.3) support both the v0 and v1 api routes so we're not running into the same issue on those.
Hitting the /v1 route of our new deployment (with curl, postman, etc) works as expected.

Are there any plans to publish a new (8.7.x ?) package ? I can see that there is an update from a couple months ago resolving this issue (9bd804a#diff-56e9f5dcb210718962163c215b0afd7cfd96c9838bc569a82489faf0fa30f604R904) but they're not present in the latest (8.6.0) @elastic/enterprise-search package published to npm.

Your Environment

  • node version: 18
  • @elastic/enterprise-search version: 8.6.0
  • os: Linux
  • Elastic Cloud deployment version: 8.7

Type is wrong about SearchRequest['body']['boost']

πŸ› Bug Report

Type is wrong about SearchRequest['body']['boost'] in enterprise-search/lib/api/app/types.d.ts.
So, It needs to fix "boost" to "boosts".

export interface SearchRequest {
    /**
     * Name of the engine
     */
    engine_name: string;
    body?: {
        query: string;
        analytics?: {};
        boost?: {};  // Fix: boost => boosts
        facets?: {};
        filters?: {};
        group?: {};
        page?: {
            current?: number;
            size?: number;
        };
        result_fields?: {};
        search_fields?: {
            [k: string]: {
                weight?: number;
            };
        };
        sort?: Array<{
            [k: string]: ('asc' | 'desc') | {
                center?: string | Array<{
                    [k: string]: unknown;
                }>;
                order?: 'asc' | 'desc';
                mode?: 'min' | 'max' | 'median' | 'avg';
            };
        }>;
    };
}

To Reproduce

  • to reproduce code
{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "test.js",
  "scripts": {
    "start": "node elasticSearch.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@elastic/elasticsearch": "^8.6.0",
    "@elastic/enterprise-search": "^8.6.0",
  }
}
const ElasticAppClient = require('@elastic/enterprise-search’);

const elasticAppClient = new ElasticAppClient.Client({
  url: '${APP_SEARCH_REQUEST_PATH}',
  auth: { token: '' },
});

const test = async () => {
    const response = await elasticAppClient.app.search({
        engine_name: β€˜${ENGINE_NAME}’,
        body: {
            query: '${SEARCH_STRING}’,
            search_fields: {
                testFields1: { weight: 1 },
             },
        },
        boost: {
            testFields2: {
                function: 'logarithmic',
                type: 'functional',
                factor: 1.2,
                operation: 'multiply',
            },
        },
    });
    console.log(response);
}

test();

Expected behavior

It's given a exception about ResponseError: {"errors":["Options contains invalid key: boost"]}

  • results
ResponseError: {"errors":["Options contains invalid key: boost"]}
    at Transport.request (/Users/home/Documents/coding/working/ node-play-ground/node_modules/@elastic/transport/lib/Transport.js:479:27)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async AppSearchClient.search (/Users/home/Documents/coding/working/ node-play-ground/node_modules/@elastic/enterprise-search/lib/api/app/api.js:610:16)
    at async test2 (/Users/home/Documents/coding/working/ node-play-ground/elasticSearch.js:1243:22)
    at async run (/Users/home/Documents/coding/working/ node-play-ground/elasticSearch.js:1290:5) {
  meta: {
    body: { errors: [Array] },
    statusCode: 400,
    headers: {
      'cache-control': 'no-cache',
      'content-length': '50',
      'content-type': 'application/json;charset=utf-8',
      date: 'Thu, 09 Feb 2023 10:39:52 GMT',
      server: 'Jetty(9.4.43.v20210629)',
      vary: 'Origin',
      'x-app-search-version': '8.6.1',
      'x-cloud-request-id': '****',
      'x-found-handling-cluster': '****',
      'x-found-handling-instance': '****',
      'x-request-id': '****',
      'x-runtime': '0.067584'
    },
    meta: {
      context: null,
      request: [Object],
      name: 'app-search',
      connection: [Object],
      attempts: 0,
      aborted: false
    },
    warnings: [Getter]
  }
}

Your Environment

  • node version: 14.19.3
  • @elastic/enterprise-search version: >=8.6.0
  • os: Mac

Is this package still maintained?

πŸ’¬ Questions and Help

Hello, is this package maintained or do you advise enterprise app search users to use another client? It seems you are not responding to the issues raised and since the version is behind of the official elasticsearch version, mismatches occur that blocks us from using it.

There are so many different clients from elastic to choose from and it has made it hard for us to navigate to which one is the correct one we should use in our case (enterprise app search in NodeJS).

Thanks, hope to get a reply!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.