Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Search settings: Match search terms in any order?
I have a custom field that contains one or more human names listed in a common citation format. Using wet_haystack to make that field and others searchable, I found that Textpattern can find articles containing listed names only when the name is entered exactly as it appears in the field:
Case A- Custom field content
John Stephens
- Search query
John Stephens
- Result
- Search returns the articles with “John Stephens” in the custom field
- Custom field content
Stephens, John
- Search query
John Stephens
- Result
- Search does not return the articles with “Stephens, John” in the custom field
My goal is to get the search query for case B to return results where the last name is first in the custom field.
Uli suggested I look at smd_fuzzy_find, but I already use that plugin, and it doesn’t trigger because the names appear in other contexts. He also recommended ob1_advanced_search which includes this feature.
I examined the manual for ob1_advanced_search, and it’s very intimidating. It appears to have a lot of complicated moving parts that I don’t need, and I’m very reluctant to add an orphaned plugin to a client’s professional public website.
Are there any other options or suggestions? If you or a loved one have considered this issue before, I’d be very grateful for any guidance you might provide!
Last edited by johnstephens (2014-02-25 01:36:45)
Offline
Re: Search settings: Match search terms in any order?
Hi John. I guess it is obvious but do you use @search=“any”@ @match=“any”@ in the search_input
?
Last edited by colak (2014-02-25 18:33:06)
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Offline
Re: Search settings: Match search terms in any order?
Hi Oleg,
Indeed. You are right. I corrected it above
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
#5 2014-02-25 14:18:25
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,315
Re: Search settings: Match search terms in any order?
colak wrote #279211:
I guess it is obvious but do you use
search="any"
in thesearch_input
?
Ouch, that’s embarassing, completely forgot about that attribute. Threw it in the search_input
tag in each page (still TXP default), and it still doesn’t bring up the expected results. Probably even more embarrassing for me. Good that it’s the sandbox.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: Search settings: Match search terms in any order?
I feel like a fool. I have always used my own custom search input instead of the txp:search_input tag, and I was unaware of the match
attribute. Thank you all so much!
Heads up to anyone finding this thread in the future: If you are using a custom search form, it is insufficient (and unnecessary) to add the match attribute to the search_input tag:
<txp:search_input form="my_search_form" match="all"/>
Instead, you need to add the a hidden input field to the form, like so:
<input type='hidden' value='all' name='m'/>
<input type='search' name='q' value='' placeholder='Enter the best keywords ever'/>
<input type='submit' value='Search'/>
- Question
- Is there any difference between using the search_input tag with a form declared in the
form
attribute, and simply using output_form?
Offline
Re: Search settings: Match search terms in any order?
johnstephens wrote #279264:
Is there any difference between using the search_input tag with a form declared in the form attribute, and simply using output_form?
the only difference is that <txp:search_input />
retains the value of <txp:search_term />
, though you can set it manually.
Offline