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.

Support nested list of objects

See original GitHub issue

In our scenario, we would like to provide full-text search functionality for datasets look like:

{
  "id":"12345",
  "name":"dataset_name",
  "type":"table",
  "columns":[
    {
      "name":"date",
      "type":"int",
      "description":"xxx"
    },
    {
      "name":"container",
      "type":"string",
      "description":"xxx"
    },
    {
      "name":"container_position",
      "type":"int",
      "description":"xxx"
    }
  ]
}

when search container, we hope it could find out all columns having container in its name field. Here is an example:

[
  {
    "id":"12345",
    "...": "...",
    "match":{
      "container":[
        "columns[1].name",
        "columns[2].name"
      ],
      "probably there will be better ways"
    }
  }
]

Looks like currently there is no good way to support this feature. Any thoughts?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
springupercommented, May 13, 2022

thank you so much, @lucaong , it works for me!

1reaction
lucaongcommented, Apr 26, 2022

A quick and dirty example of what I meant in my previous comment is this function, that given a matched term and the text of the field that matched it, returns the offsets at which the term is found:

const getMatchOffsets = (term, text) => {
  const termRegexp = term.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
  const matches = [...text.matchAll(new RegExp(termRegexp, 'gi'))]
  return matches.map((match) => [match.index, match.index + term.length])
}

getMatchOffsets('foo', 'the foo in the Foo bar')
// => [ [4, 7], [15, 18] ]

The matched terms and the name of the fields in which they are found are in the match attribute in MiniSearch results. A function like the one above could be used on the results of a search to help highlighting matches, if that is your goal.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nested list in component from array of objects - Stack Overflow
I'm searching for a little help/advice. I had a task to create a multiple nested list from array of object. I did this,...
Read more >
4.3. Grouping Objects Using Lists and Nested For Loops
While we can use the get method to access any item in the list by specifying its position, it only returns the value...
Read more >
Nested - OpenSearch documentation
A nested field type is a special type of object field type. ... Each of the objects in the array is dynamically mapped...
Read more >
27.5. Handling Nested Lists: the Flatten Function - SCons
SCons supports a Flatten function which takes an input Python sequence (list or tuple) and returns a flattened list containing just the individual...
Read more >
Saving Object with nested List of Objects #837 - hivedb/hive
I have a Custom-Class which also has a field with another Custom-Class: part 'hive_vitals_interface.g.dart'; @HiveType(typeId: 1) class ...
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