Giter VIP home page Giter VIP logo

Comments (6)

joemcelroy avatar joemcelroy commented on May 29, 2024

Hiya could you share the configuration aswell? Maybe there’s a bug here with object fields

from searchkit.

ThomasJejkal avatar ThomasJejkal commented on May 29, 2024

I'm afraid it's too simple to contain any bugs, but let's have a look:

const sk = new Searchkit({
  connection: {
    host: "http://localhost:9200",
  },
  search_settings: {
    search_attributes: ['metadata.titles.value', 'metadata.publisher'],
    result_attributes: ['metadata.titles.value', 'metadata.publisher'],
    highlight_attributes: ['metadata.publisher']
  }
})

Maybe for completeness, the rest of the code:

const searchClient = Client(sk);

function HitComponent({ hit }) {
    return <div>
        <Highlight attribute="metadata.publisher" hit={hit} />
    </div>;
}

function App() {
  return (
      <InstantSearch indexName="test_index" searchClient={searchClient}>
          <Configure attributesToHighlight={['metadata']} /> {/* This can also be done in the Dashboard */}
          <SearchBox />
          <Hits hitComponent={HitComponent}/>
      </InstantSearch>
  );
}

Adding the Configure-Component was a hint I received from the Algolia guys, but it had no effect.

from searchkit.

joemcelroy avatar joemcelroy commented on May 29, 2024

could you try this with another field thats not using object field? IE, make 'metadata.publisher just publisher and try? When I have some time, will create a test case for this if it works to figure out the object issue.

from searchkit.

ThomasJejkal avatar ThomasJejkal commented on May 29, 2024

I've already checked this yesterday and I just realized that I did not submit my comment. -.-
As expected, with a simple key it is working as intended as the response is similar to my 'hack' where I modified the result via

hit._highlightResult['test'] = hit._highlightResult['metadata.publisher'];

from searchkit.

joemcelroy avatar joemcelroy commented on May 29, 2024

sounds like a bug within Searchkit for highlighting on object fields. This is the code for highlighting and tests. Likely will take me next weekend to look into this but very happy for a PR to resolve the issue if you can.

Joe

from searchkit.

joemcelroy avatar joemcelroy commented on May 29, 2024

found the issue that instantsearch requires object fields to be represented in a object hierarchy, not currently as a 1 depth dot notation keys. Fixed this by transforming ES dot notation keys into an object hierarchy.

Got a PR fixing this and should work. Let me know if you have issues.

from searchkit.

Related Issues (20)

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.