|
@@ -129,9 +129,19 @@ function materio_search_api_results_search(){
|
|
|
//dsm("materio_search_api_results_search");
|
|
|
|
|
|
// retreive typed words separated by slashes as a sentence
|
|
|
- $keys = func_get_args();
|
|
|
+ $args = func_get_args();
|
|
|
// dsm($args, 'args');
|
|
|
- $typed = implode('/', $keys);
|
|
|
+
|
|
|
+ $keys = $args;
|
|
|
+ // $keys = explode(' ',implode(' ',$args));
|
|
|
+ // dsm($keys, 'keys');
|
|
|
+
|
|
|
+ $typed = implode(' ', $keys);
|
|
|
+ // dsm($typed, 'typed');
|
|
|
+
|
|
|
+ # with parse mode terms we use a single string of words seperated by spaces wich will be OR or AND regarding the conjunction query option
|
|
|
+
|
|
|
+ # had to add q.op = OR on solr requesthandler on solrconfig.xml
|
|
|
|
|
|
// remove query page params
|
|
|
preg_match_all('/\?page=([0-9]+)/', $typed, $pages);
|
|
@@ -158,6 +168,7 @@ function materio_search_api_results_search(){
|
|
|
$results = msa_solrquery_materiauxbreves($typed, $language, $user, $offset, $limit);
|
|
|
}
|
|
|
# only breves search (+ related materials)
|
|
|
+ # not used anymore as free users not exists anymore
|
|
|
else if(user_access('use materio search api for breves')){
|
|
|
// dsm('limited search');
|
|
|
$results = msa_solrquery_breves($typed, $language, $user, $offset, $limit);
|
|
@@ -201,7 +212,7 @@ function materio_search_api_results_search(){
|
|
|
return $ret;
|
|
|
}
|
|
|
|
|
|
-function msa_solrquery_materiauxbreves($typed, $language, $user, $offset, $limit){
|
|
|
+function msa_solrquery_materiauxbreves($keys, $language, $user, $offset, $limit){
|
|
|
// dsm($offset, 'offset');
|
|
|
// dsm($limit, 'limit');
|
|
|
|
|
@@ -218,21 +229,21 @@ function msa_solrquery_materiauxbreves($typed, $language, $user, $offset, $limit
|
|
|
? $user->data['materiosearchapi_bundlesfilter']
|
|
|
: $default_bundles;
|
|
|
|
|
|
- # choose solr query options
|
|
|
- $query_options = array('conjunction'=>'OR', 'parse mode'=>'direct');
|
|
|
|
|
|
|
|
|
-
|
|
|
- // -- -- taxo search -- -- //
|
|
|
+ // -- -- taxo search AND -- -- //
|
|
|
|
|
|
|
|
|
# define search api solr index
|
|
|
$taxo_index_machine_name = variable_get('taxonomysearchindex_'.$language->language, -1);
|
|
|
$taxo_index = search_api_index_load($taxo_index_machine_name);
|
|
|
|
|
|
+ # choose solr query options
|
|
|
+ $query_options = array('conjunction'=>'AND', 'parse mode'=>'terms');
|
|
|
+
|
|
|
#create the solr query for taxonomy search
|
|
|
$taxo_query = search_api_query($taxo_index_machine_name, $query_options)
|
|
|
- ->keys($typed);
|
|
|
+ ->keys($keys);
|
|
|
|
|
|
# apply bundle options to solr query if usefull
|
|
|
if(count($bundles_filter)){
|
|
@@ -248,11 +259,13 @@ function msa_solrquery_materiauxbreves($typed, $language, $user, $offset, $limit
|
|
|
# add user access solr query option
|
|
|
$taxo_query->setOption('search_api_access_account', $user);
|
|
|
|
|
|
+ $taxo_query->setOption('q.op', 'OR');
|
|
|
+
|
|
|
#execute first time to get the all items, to be able to filter the full text research
|
|
|
$taxo_total_results = $taxo_query->execute();
|
|
|
// dsm($taxo_total_results, "taxo total results");
|
|
|
|
|
|
- #add range to retriev the real current results
|
|
|
+ # add range to retriev the real current results
|
|
|
$taxo_query->range($offset, $limit);
|
|
|
|
|
|
# execute solr query and record results
|
|
@@ -276,9 +289,12 @@ function msa_solrquery_materiauxbreves($typed, $language, $user, $offset, $limit
|
|
|
#then calculate the good offset and limit for the complementary search
|
|
|
$fulltxt_offset = $offset - $taxo_results['result count'];
|
|
|
|
|
|
+ # choose solr query options
|
|
|
+ $query_options = array('conjunction'=>'OR', 'parse mode'=>'terms');
|
|
|
+
|
|
|
#create the solr query for taxonomy search
|
|
|
$fulltxt_query = search_api_query($fulltxt_index_machine_name, $query_options)
|
|
|
- ->keys($typed)
|
|
|
+ ->keys($keys)
|
|
|
->range(($fulltxt_offset > 0 ? $fulltxt_offset : 0), $limit); // change offset to match with the first query (taxonomy)
|
|
|
|
|
|
# apply bundle options to solr query if usefull
|
|
@@ -395,6 +411,8 @@ function msa_solrquery_breves($typed, $language, $user, $offset, $limit){
|
|
|
* materio_search_api_actuality()
|
|
|
*
|
|
|
*/
|
|
|
+# only breves search (+ related materials)
|
|
|
+# NOT USED ANYMORE as free users not exists anymore
|
|
|
function materio_search_api_actuality(){
|
|
|
global $user;
|
|
|
|