You are here

function DrupalSolrMatchTestCase::_testQueries in Apache Solr Search 6.2

Same name and namespace in other branches
  1. 8 tests/solr_index_and_search.test \DrupalSolrMatchTestCase::_testQueries()
  2. 6.3 tests/solr_index_and_search.test \DrupalSolrMatchTestCase::_testQueries()
  3. 6 tests/solr_index_and_search.test \DrupalSolrMatchTestCase::_testQueries()
  4. 7 tests/solr_index_and_search.test \DrupalSolrMatchTestCase::_testQueries()

Run predefine queries looking for indexed terms.

1 call to DrupalSolrMatchTestCase::_testQueries()
DrupalSolrMatchTestCase::testMatching in tests/solr_index_and_search.test
Test search indexing.

File

tests/solr_index_and_search.test, line 100
Tests for the apachsolr module: index and search.

Class

DrupalSolrMatchTestCase
@file Tests for the apachsolr module: index and search.

Code

function _testQueries() {

  /*
    Note: OR queries that include short words in OR groups are only accepted
    if the ORed terms are ANDed with at least one long word in the rest of the query.

    e.g. enim dolore OR ut = enim (dolore OR ut) = (enim dolor) OR (enim ut) -> good
    e.g. dolore OR ut = (dolore) OR (ut) -> bad

    This is a design limitation to avoid full table scans.

    APACHESOLR NOTE: These are not all in lucene syntax... @TODO.  Still works for text searching
  */
  $queries = array(
    // Simple AND queries.
    'ipsum' => array(
      1,
    ),
    'enim' => array(
      4,
      5,
      6,
    ),
    'xxxxx' => array(),
    'enim minim' => array(
      5,
      6,
    ),
    'enim xxxxx' => array(),
    'dolore eu' => array(
      7,
    ),
    'dolore xx' => array(),
    'ut minim' => array(
      5,
    ),
    'xx minim' => array(),
    'enim veniam am minim ut' => array(
      5,
    ),
    // Simple OR queries.
    'dolore OR ipsum' => array(
      1,
      2,
      7,
    ),
    'dolore OR xxxxx' => array(
      2,
      7,
    ),
    'dolore OR ipsum OR enim' => array(
      1,
      2,
      4,
      5,
      6,
      7,
    ),
    'minim dolore OR ipsum OR enim' => array(
      5,
      6,
      7,
    ),
    'xxxxx dolore OR ipsum' => array(),
    // Negative queries.
    'dolore -sit' => array(
      7,
    ),
    'dolore -eu' => array(
      2,
    ),
    'dolore -xxxxx' => array(
      2,
      7,
    ),
    'dolore -xx' => array(
      2,
      7,
    ),
    // Phrase queries.
    '"dolore sit"' => array(
      2,
    ),
    '"sit dolore"' => array(),
    '"am minim veniam es"' => array(
      6,
      7,
    ),
    '"minim am veniam es"' => array(),
    // Mixed queries.
    '"am minim veniam es" OR dolore' => array(
      2,
      6,
      7,
    ),
    '"minim am veniam es" OR "dolore sit"' => array(
      2,
    ),
    '"minim am veniam es" OR "sit dolore"' => array(),
    '"am minim veniam es" -eu' => array(
      6,
    ),
    '"am minim veniam" -"cillum dolore"' => array(
      5,
      6,
    ),
    '"am minim veniam" -"dolore cillum"' => array(
      5,
      6,
      7,
    ),
    'xxxxx "minim am veniam es" OR dolore' => array(),
    'xx "minim am veniam es" OR dolore' => array(),
  );
  foreach ($queries as $query => $results) {
    $response = $this->solr
      ->search($query);
    $this
      ->_testQueryMatching($query, $response->response->docs, $results);

    //@TODO: We might get to this later

    #$this->_testQueryScores($query, $response->responses->docs, $results);
  }
}