question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Signed search keys are not supported for all query types

See original GitHub issue

When instantiating an AppSearchAPIConnector, you can provide a signed search key rather than the public search key. Here’s an example JSON object that we’re passing in a signed key for some queries:

{
  "result_fields": {
    "full_name": {"raw": {}, "snippet": {"size": 100, "fallback": true}},
    "url": {"raw": {}},
  },
  "filters": {"is_public": "true"},
}

This works as expected when running the setSearchTerm action with default options (i.e. hitting the search.json endpoint). However, when running with the autocompleteSuggestions option set to true (i.e. hitting the /query_suggestion endpoint), these requests can fail, with the following response:

[400] Options contains invalid keys: result_fields and filters

This is because the options encoded in the JWT are applied to all query requests, and autocomplete queries do not support the result_fields and filters options that regular queries do.

A few possible solutions:

  • Document this as expected behavior and recommend using separate connector and driver instances when you need to support both normal and autocomplete queries
  • Add an option to the connector to pass a different searchKey when performing autocomplete queries
  • Add an option to setSearchTerm to pass a different searchKey on a per-query basis that overrides the key that was set when instantiating the connector

// pinging @JasonStoltz because we discussed this earlier today on Slack

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:4
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
JasonStoltzcommented, Jul 31, 2020

@TCMiranda I’ve responded to your issue in elastic/app-search-javascript. Let’s keep that conversation separate!

0reactions
TCMirandacommented, Jun 2, 2020

Oh, I think this is a different issue! The second request is made to get disjunctive facets, right?

But in my case, I had no filters, which caused the request to be made this way: Screenshot from 2020-06-02 11-34-24

If I remove this empty filter property, it works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Authentication | Elastic App Search Documentation [8.5]
Signed search keys keep your read only Private API Keys secret and restrict what a user can search over. They can be used...
Read more >
Common errors when you run an append query
Getting an error when you try to run an append query in an Access desktop database? Here are some hints to fix the...
Read more >
Querying the Current Configuration State of AWS Resources
The query language supports querying AWS resources based on CI properties of all AWS resource types supported by AWS Config, including configuration data, ......
Read more >
Authenticate using API keys - Google Cloud
When you use an API key to authenticate to an API, the API key does not identify a principal, nor does it provide...
Read more >
Search REST API Reference - Algolia
A private API key (can be any API key that isn't the admin key), ... Like for a regular search query, the counts...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found