Excerpts still not working on partial matches?

466 views
Skip to first unread message

Sjors

unread,
Jun 30, 2011, 6:09:09 PM6/30/11
to Thinking Sphinx
I was wondering if this problem is still around or if I'm doing
something wrong. In 2009 Pat wrote [0] that you can't get excerpts on
partial matches, that this was due to a "bug" in Sphinx itself and
that this might get fixed in the near future.

I'm using the latest version of Sphinx from SVN and thinking-sphinx
2.0.5. I can get excerpts on full word matches, but not on partial
word matches.

Cheers,

Sjors

[0]
http://groups.google.com/group/thinking-sphinx/browse_thread/thread/b9c0028c838586f4/987597b694b2277d?lnk=gst&q=partial#987597b694b2277d

Pat Allan

unread,
Jul 2, 2011, 12:14:47 AM7/2/11
to thinkin...@googlegroups.com
Hi Sjors

This is now possible in Sphinx - and should be fine with Thinking Sphinx provided you're using wildcards in your query. For example:

ThinkingSphinx.search('pow*').first.last_name #=> "Power"
ThinkingSphinx.search('pow*').first.excerpts.last_name #=> "<span class=\"match\">Power</span>"

How are you using it where it's not working?

--
Pat

> --
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To post to this group, send email to thinkin...@googlegroups.com.
> To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
>

Sjors

unread,
Jul 6, 2011, 3:30:46 PM7/6/11
to Thinking Sphinx
Hi Pat,

I wasn't using wildcards, because I want it to return partial matches
without the user typing "*" (especially with autocomplete). So I only
set:
:min_infix_len => 1

After adding
:enable_star => 1
all search results have excerpts, so that's good.

As a workaround, I can simply add "*" to all search queries in the
controller so the user doesn't have to type "*".

Thanks,

Sjors

On 1 jul, 21:14, Pat Allan <p...@freelancing-gods.com> wrote:
> Hi Sjors
>
> This is now possible in Sphinx - and should be fine with Thinking Sphinx provided you're using wildcards in your query. For example:
>
>   ThinkingSphinx.search('pow*').first.last_name #=> "Power"
>   ThinkingSphinx.search('pow*').first.excerpts.last_name #=> "<span class=\"match\">Power</span>"
>
> How are you using it where it's not working?
>
> --
> Pat
>
> On 01/07/2011, at 8:09 AM, Sjors wrote:
>
>
>
>
>
>
>
> > I was wondering if this problem is still around or if I'm doing
> > something wrong. In 2009 Pat wrote [0] that you can't get excerpts on
> > partial matches, that this was due to a "bug" in Sphinx itself and
> > that this might get fixed in the near future.
>
> > I'm using the latest version of Sphinx from SVN and thinking-sphinx
> > 2.0.5. I can get excerpts on full word matches, but not on partial
> > word matches.
>
> > Cheers,
>
> > Sjors
>
> > [0]
> >http://groups.google.com/group/thinking-sphinx/browse_thread/thread/b...

Pat Allan

unread,
Jul 6, 2011, 9:20:51 PM7/6/11
to thinkin...@googlegroups.com
You can also pass :star => true into the search query, and it'll automatically add prefix and suffix stars to each word in the search query.

Cheers

--
Pat

Pat Allan

unread,
Oct 15, 2012, 7:09:40 AM10/15/12
to thinkin...@googlegroups.com
You can change the excerpts highlight tags using something like this:

Model.search 'foo',
:excerpt_options => {:before_match => '<em>', :after_match => '</em>'}

Just make those empty strings if you don't want any highlighting of matches at all.

--
Pat

On 13/10/2012, at 10:28 AM, Taiwo wrote:

> were u able to remove the span tags that show up when using excertps??
>
> Thanks
>
> taiwo

> To view this discussion on the web visit https://groups.google.com/d/msg/thinking-sphinx/-/ypImiQ5023wJ.

Andrey Eremin

unread,
May 22, 2014, 9:35:53 AM5/22/14
to thinkin...@googlegroups.com
It it possible to highlight only matched part? For example return ThinkingSphinx.search('pow').first.excerpts.last_name #=> "<span class=\"match\">Pow</span>" 
So NOT to match a whole word.

понедельник, 15 октября 2012 г., 15:10:07 UTC+4 пользователь Pat Allan написал:

Walter Lee Davis

unread,
May 22, 2014, 10:21:44 AM5/22/14
to thinkin...@googlegroups.com
I believe that Sphinx shows you what it matched after doing any stemming or fuzzy matching, not precisely the string you entered. From it's point of view, that's the "match". If you wanted to highlight the precise string entered, you may want to look at a JavaScript solution instead of using the Sphinx highlighter.

Walter
> To unsubscribe from this group and stop receiving emails from it, send an email to thinking-sphi...@googlegroups.com.
> To post to this group, send email to thinkin...@googlegroups.com.
> Visit this group at http://groups.google.com/group/thinking-sphinx.
> For more options, visit https://groups.google.com/d/optout.

Pat Allan

unread,
May 22, 2014, 10:43:17 AM5/22/14
to thinkin...@googlegroups.com
Hi Andrey

I have a feeling what you want is not possible, but I’m not sure. It’s a question that’s probably better to direct to the Sphinx team - Thinking Sphinx just uses the excerpts functionality of Sphinx itself.

— 
Pat

To unsubscribe from this group and stop receiving emails from it, send an email to thinking-sphi...@googlegroups.com.
To post to this group, send email to thinkin...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages