With dev cvs checkout, re-indexed site, and results were returned on the http://localhost:8983 but not on drupal's /search/apachesolr_search

noticed that the object Solr_Base_Query->_field_operator = 'AND'
the Solr_Base_Query constructor now defaults 'AND' to _field_operator

 -  function __construct($query) {
+  function __construct($querystring, $field_operator = "AND") {

so added '' to the function call so that 'AND' not restricting the search results.

CommentFileSizeAuthor
apachesolr_field_operator.patch713 bytesaufumy

Comments

aufumy’s picture

Status: Active » Needs review
robertdouglass’s picture

Status: Needs review » Needs work

Interesting. I don't quite understand how this problem is occurring because "AND" is simply ignored to begin with, as can be seen in this function (Solr_Base_Query.php):

  private function rebuild_query() {
    $fields = array();
    foreach ($this->_fields as $pos => $values) {
      $fields[] = Solr_Base_Query::make_field($values);
    }
    
    $join_delim = $this->_field_operator == 'AND' ? ' ' : ' OR ';
    $this->_query = trim(implode($join_delim, array_filter($fields, 'trim')));
    foreach ($this->_subqueries as $id => $data) {
      $operator = $data['#operator'];
      $subquery = $data['#query']->get_query();
      $this->_query .= " {$operator} ({$subquery})";
    }
  }

@aufumy - the approach of your patch isn't really correct. You shouldn't need the second parameter - letting it default to "AND" should not be a problem. Can you try to track down how exactly it is failing? Thanks!

aufumy’s picture

Without the second parameter, on search
* rebuild_query() is called 4 times
** _query => test, 'test hash:09defabc5a9d20490be2c56c9484ac0c', 'test hash:09defabc5a9d20490be2c56c9484ac0c', test

With passing '' as the second parameter, on search
* rebuild_query() is called 12 times
** _query => test, 'test OR hash:09defabc5a9d20490be2c56c9484ac0c', 'test OR hash:09defabc5a9d20490be2c56c9484ac0c', test, 'test OR uid:1', test, test, 'test OR type:discussion', test, 'test OR type:group', test, 'test OR type:story'

aufumy’s picture

My mistake, it appears that there is an issue with the passing of the hash, the patch above is not needed.

On the dev server there are multiple solr instances.

aufumy’s picture

I have deleted index, and run update many times over, to try to understand why it does not work on the dev site, but works on my local.

The hash passed upon update_index is the same that is passed when searching, but on the dev site, passing the hash upon search returns no search results.

Commented out these lines for apachesolr_search.module

  $hash = md5(url(NULL, array('absolute' => TRUE)));
  $query->add_field('hash', $hash);
robertdouglass’s picture

So what is an appropriate title for this issue at the moment? As I understand it you're having problems moving a site between a local development environment and a remote development site? This would make sense because we're using the URL of the current site to generate the hash. I'd expect that reindexing after the move would fix the problem.

Please rename the issue and describe in more detail what your workflow is. Thanks!

aufumy’s picture

Hi Robert

I am pretty stumped by the behavior, but I wanted to document.

My local environment is actually newer than the dev. The dev has not been copied from local.
On my local environment I am using jetty and on the dev it is tomcat I believe.

On the dev environment, I have attempted to debug by
* echoing the hash for search results in function apachesolr_search_search
* deleting the index, echoing the hash in function update_index that is shown when cron is run
* comparing the hash it appears identical
* however when running search no results are shown, unless hash not added as field in search (apachesolr_search_search)

Thanks
Audrey

aufumy’s picture

Title: No results on search page displayed as 'AND' added to _field_operator by default » Hash field on dev server (but not local) excluding search results
Status: Needs work » Postponed (maintainer needs more info)
aufumy’s picture

Status: Postponed (maintainer needs more info) » Fixed

The latest cvs checkout of apachesolr works fine as is on the dev box (wrt to hash).

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.