I am trying to build a Zend_Gdata_Spreadsheets_ListQuery and I can't find any references that explain what the expected query syntax is and what types of queries you can and cannot perform. The closest I have been able to come to finding anything is the [Google Data APIs Client Library (1.41.1)] (https://developers.google.com/gdata/javadoc/com/google/gdata/client/spreadsheet/ListQuery#ListQuery(java.net.URL)), which describes the function setSpreadsheetQuery as follows:
setSpreadsheetQuery
public void setSpreadsheetQuery(java.lang.String query) Sets the
structured spreadsheet query. Parameters: query - the query such as
"name = 'Sonja' and state = 'Georgia'"
This works just fine if you are looking for a cell whose column title is "name" and that contains the text "Sonja"—and nothing else. I am looking for cells containing "Sonja" as part, of the cell's text. A cell in the "name" column with the value "Sonja the Awesome" for example, would not match the search above. name=Sonya* causes an error and name="Sonya*" returns no results.
So, does anybody know where I can find a rundown of what the expected "structure" for the "structured spreadsheet query" is?
Have you tried using regex ? Also, make sure to escape the regex special characters.
Something like \bSonja\b
Related
I am using Laravel 5.3 and Algolia,
I want to highlight the search result,I read the documentation but I still don't know how to do it.
https://www.algolia.com/doc/api-client/php/parameters#attributestohighlight
Any ideas?
When search results are returned from Algolia, they will wrap the "highlighted part" with <em> </em> tags by default. This happens right out of the box, so all you really need to do is use CSS to customize the look of <em>s within your search results div to get the effect you want.
Of course if you prefer that they wrap highlighted text in something other than <em> then you can customize it with anything you wish (such as maybe a span tag with a "highlighted-search" class or something). You customize this when initializing the search in your PHP.
$index = $client->initIndex('contacts');
$result = $index->search('search query', ['attributesToRetrieve' => 'firstname,lastname', 'hitsPerPage' => 50, 'highlightPreTag' => '<span class="highlighted-search">', 'highlightPostTag' => '</span>']);
Now let's say you search 'John D' and submit that search query. Algolia will return a string to the effect of:
<span class="highlighted-search">John D</span>oe
Now with your CSS you customize it like
span.highlighted-search {
background-color:yellow;
}
and now it will highlight the search query with yellow.
Of course this is all assuming you want the static (PHP Library) server side search results. I highly recommend that you use the autocomplete.js library so you can get live search results as you type. This requires using the js libraries to return results client-side while the user types. It is a much better experience.
In each item returned by the search engine, there is an extra "_highlightResult" attribute that contains some metadata and the value of the searchable attributes modified with search terms surrounded with <em>.
For instance, for the search term "toux", the returned JSON will looks like:
{
"medicament" : "VICKS TOUX SECHE 7,33 mg ADULTES MIEL, pastille",
"_highlightResult" : {
"medicament" : {
"value" : "VICKS <em>TOUX</em> SECHE 7,33 mg ADULTES MIEL, pastille",
"matchedWords" : ["toux"]
....
...
}
To highlight the search results, with the search terms, you simply have to display the attribute value under "_highlightResult" instead of the raw one.
If you are not using it already, I would recommend you to use Instantsearch.js.
Highlighting the typed keywords of the search results is dealt whitin the hits widget the same way, in its templates.item parameter.
You may find live code example of this feature here https://community.algolia.com/instantsearch.js/examples/
So my solr query is implemented in two parts,first query does an exact search if there are no results found for exact then it goes to the second query that does a fuzzy search.
every things works fine but in situations like-->A user enters "burg +"
So in exact search no records will come,so second query is called to do a fuzzy search.Now comes the problem my fuzzy query does not understand special characters like +,-* which throws and error.If i dont pass special characters it works fine. But in real world a user can put characters with their search,which will throw an error.
Now iam stuck in this and dont know how to resolve this issue.
This is how my exact search query looks like
$query1="(business_name:$data*^100 OR city_name:$data*^1 OR
locality_name:$data*^6 OR business_search_tag_name:$data*^8 OR
type_name:$data*^7) AND (business_active_flag:1) AND
(business_visible_flag:1) AND (delete_status_businessmasters:0)";
This is how my fuzzy query looks like
$query2='(_query_:%20"{!complexphrase%20qf=business_name^100+type_name^0.4+locality_name^6%27}%20'.$url_new.')AND(business_active_flag:1)AND(business_point:[1.5 TO 2.0])&q.op=AND&wt=json&indent=true';
This is the error iam getting
Cannot parse ' must~1 *~N': '*' or '?' not allowed as first character in WildcardQuery
Iam new to solr and dont know how to tackle this situation.
Details of what iam using
Solrphpclient
php
solr 4.9
ok so i see that you are using solrphpclient.You need to make changes in the service.php file so that these special characters get replaced to either blank or what ever you want.
This will take care of the problem you are facing
$params=str_replace("%", "", $params);
$params=str_replace("*", "", $params);
$params=str_replace("&", "", $params);
you need to put this in the search function or inside you custom function which i assume you are using for the fuzzy query
I am using zend framework, and I need to add option "where", which include commas (") it is used for filtering, tried to use it in html:
<option value=""msg":"Paid""><?php echo Core_Locale::translate('Paid')?></option>
But after turning on other page filter disappear. What I need to get using this:
{"success":true,"version":"1.0","paid":false,"added_to_balck_list":true,"msg":"Paid"}
I'm sure to get msg using fetchall and select each which is equal, but in table is tones of data and I won't use it. So guys may be you know how I can add commas in "where"?
$select->where( "response like '%$message%'");
In SQL, it should look like:
response like "msg":"Paid"
But I can't just type like %paid% because every record have Paid:true of paid paid:false and I get all the records.
I have strings of data in a field named content, one record may look something like:
loads of text ... [attr1] some text [attr2] more text [attr3] more text etc...
What I'm looking to do is get all the text within the square brackets; so that I can put it into a PHP array. Is this even possible with mySql?
I've seen the following post: Looking to extract data between parentheses in a string via MYSQL, but they are looking to only extract one value from between their parentheses, I have an unknown number of them. After reading that post I've though of doing something like the following;
SELECT substr(content,instr(content,"["), instr(content,"]")) as attrList from myTable
Which would grab me the following:
[attr1] some text [attr2] some more text [attr3]
and I can use PHP to strip the rest of the text out and then explode the string into an array, but is there a better way to do this just using mySql where I can retrieve something like:
[attr1][attr2][attr3]
I was thinking perhaps regex, but I see that just returns a true of false which doesn't help me a lot.
After even more research, I'm not sure it's possible in mySql, and I might need the results in string or array form depending on where I'm using them in my app.
So I've created a new method to return the list after I've got the data from the database (with a little help from this post: PHP: Capturing text between square brackets):
public function attrList($array=false)
{
preg_match_all("/\[.*?\]/",$this->content,$matches);
$params = str_replace(array('[',']'),'',$matches[0]);
return ($array===false) ? implode(', ',$params) : $params;
}
I am trying to insert into mysql from an xml using PHP, but the field name contains a "hyphen" and for some reason it is not inserting this field, the rest are fine. I have tried using the hex codes x002D, x2010,x2012, and none have worked. As you can see in my xml, the hyphen is not being changed like the space, but if I just remove the x002D inserts everything after the "E" in other words just inserts -mail_x0020_Address.
This is my xml:
<encuestas>
<ID>9949</ID>
<E-mail_x0020_Address>email#email.com</E-mail_x0020_Address>
<ZIP_x002F_Postal_x0020_Code>90001</ZIP_x002F_Postal_x0020_Code>
</encuestas>
This is my insert statement ( I removed fields, I have 20 on that xml):
"INSERT INTO New_Encuestas_Datos(ID,`email`,`Zip/Postal Code`) VALUES('$product->ID','$product->E-mail_x0020_Address','$product->ZIP_x002F_Postal_x0020_Code')";
The variables are coming from an array reading the xml and like I said, everything is imported except email. I have tried the following combinations:
E-mail_x0020_Address
E_x002D_mail_x0020_Address
E_x2010_mail_x0020_Address
E_x2012_mail_x0020_Address
Can anyone point me what I am doing wrong? Thanks !
Hmm, I doubt you can use it in a string, but in plain PHP it is $product->{'E-mail_x0020_Address'};. But that doesn't matter anyway, as you should escape you values prior to sending them to a database you can nicely name an escaped variable as you like.
Try using:
"INSERT INTO New_Encuestas_Datos(ID,`email`,`Zip/Postal Code`) VALUES('{$product->ID}', '{$product->E-mail_x0020_Address}', '{$product->ZIP_x002F_Postal_x0020_Code}')";
Edited:
Just found here Validate class/method names with regex that '-' is not valid in method names.