Hello/Hi/Greetings,
Is it possible to modify search.php to search "exact" term without adding "" ? Like a third options under field?
piwigo 13.5
Piwigo URL: http://
Last edited by BigIsland270972 (2023-01-31 13:58:52)
Offline
Hi. Let me explain further. When I search for "Kommune : Sande" I want the exact match for that frase. HOW?
Cheers
Offline
Offline
This is suppose to get hits from the exact phrase. Its NOT! I get hits both George AND Washington
How to fix this??
Offline
I don't know where you got it'd be supposed to search for the quoted phrase, but you can see in search.php that's not the case. Operator characters and quotes in $drop_char_match are removed and replaced by their correspondent (blank or empty) in $drop_char_replace, words split and OR or AND clause applied.
Offline
erAck wrote:
I don't know where you got it'd be supposed to search for the quoted phrase, but you can see in search.php that's not the case. Operator characters and quotes in $drop_char_match are removed and replaced by their correspondent (blank or empty) in $drop_char_replace, words split and OR or AND clause applied.
AND That means what? Sorry confusing answer :)
Offline
That means that from the input the double quote characters are stripped, then the input is split as words, on which the selected AND or OR clause is applied.
Offline
erAck wrote:
That means that from the input the double quote characters are stripped, then the input is split as words, on which the selected AND or OR clause is applied.
OK! Understand. So how do I search for the exact phrase??
Last edited by BigIsland270972 (2023-01-31 13:07:36)
Offline
Interesting read on SUBJECT:
https://www.oreilly.com/library/view/my … 04s15.html
Offline
SO the short answer is YOU CAN'T do this kind of search. What a pity.
Offline
Hi, longer answer:
what about adding next to OR and AND; a third possibility approaching your desire?
in search.tpl add this line
<label><input type="radio" name="mode" value="EXACT"> {'Search for exact phrase'|@translate}</label>
in search.php add the third possibility EXACT in the checking code to get this line
check_input_parameter('mode', $_POST, false, '/^(OR|AND|EXACT)$/');
then modify code to handle an alternative preventing word splitting:
if ($_POST['mode']=='EXACT') { // Do not split words $search['fields']['allwords'] = array( 'words' => array_unique( array( str_replace( $drop_char_match, $drop_char_replace, $_POST['search_allwords'] ) ) ), 'mode' => 'AND', 'fields' => $_POST['fields'], ); } else { // Split words $search['fields']['allwords'] = array( 'words' => array_unique( preg_split( '/\s+/', str_replace( $drop_char_match, $drop_char_replace, $_POST['search_allwords'] ) ) ), 'mode' => $_POST['mode'], 'fields' => $_POST['fields'], ); }
I do not provide any warranty for this tweak, nor pretend reaching full text search holy grail.
To get closer to the aim, this just miss a way to split properly input search ["a b" c d "e f g"] in 4 parts: "a b", "c", "d", "e f g".
Offline
Thanks!
Offline
Got it working but no hits when searching for Kommune: Sande and there are a thousand image desription with that exact phrase. Try Yourself: https://www.fotoarkiv.no/search.php
Best regards
Robert
Offline
Mind removing accepted chars like ':' from $drop_char_match
Be careful with some of the others chars, the aim is not to expose your database to SQL injection.
I would try with "Kommune: Flora" because did not see any "Kommune: Sande" in my results.
Offline
TOnin wrote:
Mind removing accepted chars like ':' from $drop_char_match
Be careful with some of the others chars, the aim is not to expose your database to SQL injection.
I would try with "Kommune: Flora" because did not see any "Kommune: Sande" in my results.
Yes removed : from char_match but nether do I get any result for Kommune: Sande. STRANGE.
You can clearly se it's there: https://www.fotoarkiv.no/picture.php?/1 … af-andreas
best regards
RS
Last edited by BigIsland270972 (2023-01-31 23:43:52)
Offline