Hi Walter I don't have any easy answers for this, I'm afraid.
If you were indexing each element separately, then this would certainly be easier - but that means new models for your app, and pulling these HTML documents apart and so forth. Not fun. Another option would be to make the excepts size much larger, in the hope that an id would then be in the excerpts results... but could increase rendering time, and then you've got the fun of parsing excerpt output for ids (and ensuring you've got the closest one). Not fun either. The options, by the way, are listed here: http://sphinxsearch.com/docs/manual-2.1.7.html#api-func-buildexcerpts And can be specified within an :excerpts option in a search call: Foo.search 'bar', :excerpts => {:exact_phrase => true} Perhaps others have suggestions? -- Pat On 16 Apr 2014, at 3:18 am, Walter Lee Davis <[email protected]> wrote: > I'm trying to do the following with Sphinx search results, and I can't quite > wrap my head around how to use the excerpt function to do it. > > I have a collection of HTML documents in the database, and it's quite large > (each one is a book, as one page of HTML). Search results are naturally in > context, and the excerpt function shows the found terms highlighted, as I > expect. But now I need to anchor down to that paragraph, UL (whatever the > nearest parent container with an ID is, basically), when I link to the > results. Since the excerpt function is not aware of the content format, I'm > not sure how to go about finding this, or more accurately, avoiding having > the html cut apart by the window of the excerpt engine such that the nearest > parent ID is missing. > > Does this question make sense? Can anyone offer a suggestion? At the moment, > I am looking at creating a shadow column in my contents table with the HTML, > and a plain_text column where the actual searching takes place, and then use > a Nokogiri scraper on each search result's html to grab the nearest ID for > the hits. (So I'll be searching twice -- once in Sphinx to find the short > list of matches, and again using Nokogiri on the matches.) This will be a > bunch of work, so I'm hoping there is another way that someone else has > already figured out. > > Thanks, > > Walter > > -- > You received this message because you are subscribed to the Google Groups > "Thinking Sphinx" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/thinking-sphinx. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/thinking-sphinx. For more options, visit https://groups.google.com/d/optout.
