Fix nodeacess and Subquery handling, and fix tests

vladimir.dolgopolov - December 17, 2008 - 12:07
Project:Apache Solr Search Integration
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:won't fix
Description

Subqueries produced by Solr_Base_Query->add_subquery and Solr_Base_Query->remove_subquery are not properly generated.

#1

vladimir.dolgopolov - December 17, 2008 - 12:09

Here is the patch and tests fixing it.

AttachmentSize
Solr_Base_Query.php_.patch 1.02 KB
solr_base_query.test 1.85 KB
solr_base_subquery.test 3.03 KB

#2

Gábor Hojtsy - December 17, 2008 - 13:00

Unfortunately *.test files are not viewable on drupal.org right now. Logged a bug report on that here: http://drupal.org/node/348164

Until that is fixed, it would be a good idea if you could repost these in a patch form or as .txt files.

#3

pwolanin - December 17, 2008 - 15:23
Status:active» needs review

Yes, sorry about that - obviosuly a total bug here:$fq = $this->fq[] = implode(" {$operator} ", $subfq);

I think the patch is not quite right, however - we need to implode with the operator.

AttachmentSize
subfq-broken-348150-3.patch 1012 bytes

#4

pwolanin - December 17, 2008 - 17:29

committed the patch in #3

#5

pwolanin - December 17, 2008 - 18:26
Title:Subqueries handling works not so well» Fix nodeacess and Subquery handling, and fix tests

Seems like we need some further fixes here as well - per testing and discussion w/ Jacob.

AttachmentSize
query-nodeaccess-handling-348150-5.patch 8.31 KB

#6

vladimir.dolgopolov - December 18, 2008 - 04:05

Here is the tests from #1 renamed as txt.

AttachmentSize
solr_base_query.test.txt 1.69 KB
solr_base_subquery.test.txt 2.93 KB

#7

vladimir.dolgopolov - December 18, 2008 - 04:56

@Peter #3

I think the code:

<?php
$query1
= apachesolr_drupal_query('', 'uid:1 tid:5');
$query2 = apachesolr_drupal_query('', 'uid:10 tid:50');
$query2->add_subquery($query1, 'AND');
echo (
$query2->get_url_querystring());
?>

should produces (result of the patch #1):

filters=uid:10 tid:50 AND (uid:1 tid:5)

instead of (result of the patch #3):

filters=uid:10 tid:50 uid:1 AND tid:5

I think so because the code (notice I enter similar $keys instead of $filters param in apachesolr_drupal_query()):

<?php
$query1
= apachesolr_drupal_query('uid_1 tid_5');
$query2 = apachesolr_drupal_query('uid_10 tid_50');
$query2->add_subquery($query1, '', 'AND');
echo (
$query2->get_query_basic());
?>

produces:

uid_10 tid_50 AND (uid_1 tid_5)

P.S.
I'm thinking we should parenthesize the parent query as well:

(uid_10 tid_50) AND (uid_1 tid_5)

#8

JacobSingh - December 18, 2008 - 07:00

Hey Guys,

The nodeaccess patch above looks good, and it looks like Peter already committed it.

I made one change to use parenthesis as Vlad suggests. Attached is a patch in progress of the subquery tests being handled a little better now. Since filter queries are always AND some of the previous tests no longer make sense AFAICT.

AttachmentSize
subquery_test.diff 6.56 KB

#9

pwolanin - December 18, 2008 - 13:22

@Vladamir - I was not actually thinking about subqueries being in the URL, rather as being added later - I'm not sure that the parsing code correctly handles them from the URL.

#10

pwolanin - December 18, 2008 - 15:59

Jacob - did you commit this patch? It looks like it from the CVS log.

#11

pwolanin - December 19, 2008 - 02:46

patch to fix nodeaccess handling for mlt block queries.

AttachmentSize
mlt-nodeaccess-348150-11.patch 2.82 KB

#12

JacobSingh - December 19, 2008 - 04:15
Status:needs review» patch (to be ported)

The handler can be determined form $params if needed, otherwise, committed the above. (patch attached).

AttachmentSize
mlt-nodeaccess-348150-12.patch 3.18 KB

#13

vladimir.dolgopolov - December 19, 2008 - 12:04

There are fixed tests.

Notes:

1. solr_base_query.test
It passes if you apply the patch Pure negative queries don't work

2. solr_base_subquery.test
It includes (commented) testStaticFactory() method intended to test apachesolr_current_query() static cache. But there is a problem.

<?php
$query1
= apachesolr_current_query('foo', '', '', TRUE); // TRUE to resert. $query1 is 'foo'
$query2 = apachesolr_current_query('bar', 'title:baz'); // $query2 is 'bar?filters=title:baz'

$query2->add_subquery($query1); // $query2 should be 'bar AND (foo)?filters=title:baz' or whatever

// What should be as a result of the next line?
// a) 'bar?filters=title:baz' (not altered $query2)
// b) 'bar AND (foo)?filters=title:baz' (altered $query2)
$query3 = apachesolr_current_query('bar', 'title:baz'); // $query3 IS 'bar?filters=title:baz'
?>

The original test assumes option (b). Here I see option (a).
We shoud decide which approach to follow.

3. solr_index_and_search.test
The original one is based on search.module test so it cannot be used for testing dismax functionality.
It uses a query type 'standard'.
The dismax test will be created soon.

AttachmentSize
solr_base_query.test.txt 1.6 KB
solr_base_subquery.test.txt 3.4 KB
solr_index_and_search.test.txt 6.52 KB

#14

pwolanin - January 18, 2009 - 03:30
Status:patch (to be ported)» needs review

#15

JacobSingh - June 23, 2009 - 04:09
Status:needs review» won't fix

This is pretty ancient.

 
 

Drupal is a registered trademark of Dries Buytaert.