The 5th Annual China PHP Conference


(PECL solr >= 0.9.2)

SolrUtils::queryPhrasePrepara una frase desde una cadena lucene sin escapar


public static string SolrUtils::queryPhrase ( string $str )

Prepara una frase desde una cadena lucene sin escapar.



La frase lucene.

Valores devueltos

Devuelve la frase entre comillas dobles.

add a note add a note

User Contributed Notes 2 notes

quackfish at gmail dot com
1 year ago
You need to be careful allowing users to use raw queries if you index sensitive information. Cross domain search timing attacks can be used to extract information from an index [1] if your form does not have XSRF protection.

If you allow raw queries it can also allow users to DOS your application by inputting slow queries.

daniel dot allen at commercialtrucktrader dot com
3 years ago
Doing some tests it would appear that this function also sanitizes input(testing on version above 1.0). And the term "phrase" is not the same as a complete query like "FIELD:THE RIGHT HALF AFTER THE : IS THE PHRASE."

So if you want to search SOME_FIELD:some value with an escape character like +, then you would have to write the code out:

$query  = 'SOME_FIELD:' . SolrUtils::queryPhrase('some value with an escape character like +');

That would properly escape it like:

some value with an escape character like \+

To Top