HTML Phrase Searching

25 views
Skip to first unread message

Marvin Herbold

unread,
Nov 8, 2017, 10:58:18 AM11/8/17
to sphinx-dev
Any plans to add support for HTML phrase searching?

We are running into the issue where the search feature is becoming less and less useful as we add more more pages to our documentation.

For example, the terms "full day" when searched, currently returns dozens of hits matching both "full" and "day" in separate sentences.  But the full phrase of "full day" actually only appears in one document.

The ability to have phrase searching (perhaps by using quotes in the search bar) would be huge for us.

Komiya Takeshi

unread,
Nov 11, 2017, 4:39:07 AM11/11/17
to sphin...@googlegroups.com
Hi Marvin,

It might been requested, but we don't have concrete plan for it.

Thanks,
Takeshi KOMIYA
> --
> You received this message because you are subscribed to the Google Groups
> "sphinx-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sphinx-dev+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Marvin Herbold

unread,
Nov 13, 2017, 8:38:06 AM11/13/17
to sphinx-dev
It does not look like it would be much effort to add full phrase searching support.

Basically in somewhere searchtools.js, check if the search terms include quotes and if it does then in the ajax callback just discard all results that don't have the full search term in it.

BTW I see some code support for "excluded" words but when I try testing it out using the search terms "full -day" (meaning results with "day" should be excluded) it does not work.  It displays all docs with both "full" and "day".

Komiya Takeshi

unread,
Nov 13, 2017, 11:21:40 AM11/13/17
to sphin...@googlegroups.com
>It does not look like it would be much effort to add full phrase searching support.

Sounds good. We always welcome your contribution :-)

Marvin Herbold

unread,
Nov 14, 2017, 12:57:33 PM11/14/17
to sphinx-dev
I see what you did there.  :-)

OK here is my contribution - I added exact phrase searching, and also fixed your broken excluded keywords feature.

My version of your searchtools.js file can be found here: https://alpha-dev.usked.com/manual/internal/_static/mysearchtools.js

For exact phrase search matching I updated the code in 2 places, and you can find them by searching for /* CUSTOM SUPPORT FOR EXACT PHRASE SEARCH */

For the fix for excluded keywords, I also updated the code in 2 places.  It was actually broken for 2 reasons.  The splitQuery function stripped out the "-" so everything that checks for it later on obviously would not find them any more.  Then later on, there is a bug with using $u.contains - it does a type-aware exact value match, but you were comparing an array of ints against a string.  A simple typecast to an int fixes this part.  You can find the 2 places by searching for /* FIX FOR EXCLUDED KEYWORDS */

Komiya Takeshi

unread,
Nov 15, 2017, 10:57:32 AM11/15/17
to sphin...@googlegroups.com
Hi Marvin,

Thanks,
Could you modify it as a new pull request? I'm not good at JavaScript,
so I can't evaluate it correctly.
But other maintainers might be able to do it, I believe.

Thanks,
Takeshi KOMIYA

Marvin Herbold

unread,
Nov 21, 2017, 10:25:40 AM11/21/17
to sphin...@googlegroups.com

Done - pull requests #4253 and #4254.

--
Marvin Herbold
Director of Technology
Access Interpreting, Inc.
Website: ainterpreting.com
(480) 347-9629 (Support VP)
(571) 730-4330 (Main Office Voice)
(571) 730-4331 (Main Office Fax)
(202) 540-8617 (Main Office VP)
Reply all
Reply to author
Forward
0 new messages