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.

Multiple keys: Return matches from both keys?

See original GitHub issue

Sorry if I’m misunderstanding the documentation, but it looks to me from testing that if you specify multiple keys it will look for matches in one key or the other but not both. For example:

https://codepen.io/tarekraafat/pen/rNyBxdL

The data contains this:

    {
        "food": "Wild Boar - Tenderloin",
        "cities": "Luthu",
        "animals": "Eastern diamondback rattlesnake"
    },

A search for “wild” will return a result from that row, and a search for “luthu” will return a result from that row, but searching “wild luthu” will not return anything.

I’d like to be able to do a name search by firstname and surname so that a search for “owe leo” would return this row:

{
	"surname": "Leonard",
	"firstname": "Owen",
}

Is this currently possible?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
folknorcommented, Aug 13, 2021
new autoComplete({
	searchEngine: (q, r) => {
		if ( r.includes(q) ) {
			return r
		}
		return false
	}
})

If you don’t use config.data.keys like I said, then r will be the entire record instead of the property at the keys, so


new autoComplete({
	searchEngine: (q, r) => {
		if ( r.surname.includes(q) ) {
			return r.surname
		}
		if ( r.firstname.includes(q) ) {
			return r.firstname
		}
		return false
	}
})

1reaction
devcercommented, Aug 28, 2021

@TarekRaafat This works perfect! Thank you so much 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to return multiple keys in a string if a given string matches ...
Now, what I would like to do is return multiple keys in the same row if the values are present in the string...
Read more >
Find and Delete multiple keys matching by a pattern in Redis
scanStream accepts two options : match which defines the pattern to search for and count which limits the no of keys returned in...
Read more >
array_search - Manual - PHP
If needle is found in haystack more than once, the first matching key is returned. To return the keys for all matching values,...
Read more >
SQL Joins on Multiple Keys | Intermediate SQL - Mode Analytics
This lesson of the SQL tutorial for data analysis covers joining tables on multiple keys to boost performance and make SQL queries run...
Read more >
Foreign Key Constraint | CockroachDB Docs
A single column can have multiple foreign key constraints. For an example, see Add ... You can specify both MATCH FULL and MATCH...
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