Re: [Tracker] Is this RDF query correct?



Le jeudi 31 aoÃt 2006 Ã 20:43 +0100, Jamie McCracken a Ãcrit :
Laurent Aguerreche wrote:
Hello,

I try to use this RDF query:

....

and it fails with this message :

Error in rdf query parse: Line 12 character 1: CONTAINS element not
expected here


What is the problem? How can I do a OR between numerous 'contains'
encapsulated itself in a AND? Is it legal?

it should be but most likely its a bug.

check start_element_handler in tracker-rdf-query.c

the "state" variable refers to the previous entry on the query stack.

looking at lines 626-628, the fail check is not expecting  </rdfq:or> 
or any logic end state. I would guess adding :

|| is_end_logic (state)

to the failcheck condition should make it okay. This would need to be 
added to all the operators in that function.

Ok, you're right except it is is_end_operator(state).  :-)
(state which blocked was STATE_END_CONTAINS)


But let look this line:

if (set_error_on_fail ( state == STATE_CONDITION || is_logic (state) ||
                       ((data->current_logic_operator == LOP_AND) &&
                         is_end_operator (state)),
                       context,
                       "CONTAINS element not expected here", error)) {
        return;
}


IMHO only 'AND' operator is handled. So I replaced

  ((data->current_logic_operator == LOP_AND) && is_end_operator (state))

by

  ((data->current_logic_operator == LOP_AND ||
    data->current_logic_operator == LOP_OR)
  && is_end_operator (state))


Test for CONTAINS is currently:

state == STATE_CONDITION || is_logic (state) ||
 ((data->current_logic_operator == LOP_AND ||
   data->current_logic_operator == LOP_OR)
  && is_end_operator (state))



Now, I get that working SQL query:


Select DISTINCT Concat(S.Path, '/', S.Name)
 as uri, GetServiceName(S.ServiceTypeID)
 as stype , M0.MetaDataIndexValue
 FROM Services S
 INNER JOIN ServiceMetaData M5 ON S.ID = M5.ServiceID
 INNER JOIN ServiceMetaData M4 ON S.ID = M4.ServiceID
 INNER JOIN ServiceMetaData M3 ON S.ID = M3.ServiceID
 INNER JOIN ServiceMetaData M2 ON S.ID = M2.ServiceID
 INNER JOIN ServiceMetaData M1 ON S.ID = M1.ServiceID
 LEFT OUTER JOIN ServiceMetaData M0 ON S.ID = M0.ServiceID
  WHERE (S.ServiceTypeID between GetServiceTypeID('Files') and
GetMaxServiceTypeID('Files'))
  AND  (  (  ( MATCH (M1.MetaDataIndexValue) AGAINST ('opengl' IN
BOOLEAN MODE))
         OR  ( MATCH (M2.MetaDataIndexValue) AGAINST ('opengl' IN
BOOLEAN MODE))
         OR  ( MATCH (M3.MetaDataIndexValue) AGAINST ('opengl' IN
BOOLEAN MODE))
         OR  ( MATCH (M4.MetaDataIndexValue) AGAINST ('opengl' IN
BOOLEAN MODE))
         OR  ( MATCH (M5.MetaDataIndexValue) AGAINST ('opengl' IN
BOOLEAN MODE))  )  )
  AND (M5.MetaDataID = 1 )
  AND (M4.MetaDataID = 56 )
  AND (M3.MetaDataID = 55 )
  AND (M2.MetaDataID = 53 )
  AND (M1.MetaDataID = 52 )
  AND (M0.MetaDataID = 6 )
   LIMIT 0,512


but it returns an empty result which is impossible...



This follow RDF query returns many answers:

<rdfq:Condition>
  <rdfq:and>

    <rdfq:or>

      <rdfq:contains>
        <rdfq:Property name="File.Content" />
        <rdf:String>opengl</rdf:String>
      </rdfq:contains>
 
    </rdfq:or>

  </rdfq:and>
</rdfq:Condition>


but this one, nothing:


<rdfq:Condition>
  <rdfq:and>

    <rdfq:or>

      <rdfq:contains>
        <rdfq:Property name="Doc.Title" />
        <rdf:String>opengl</rdf:String>
      </rdfq:contains>

      <rdfq:contains>
        <rdfq:Property name="Doc.Subject" />
        <rdf:String>opengl</rdf:String>
      </rdfq:contains>

      <rdfq:contains>
        <rdfq:Property name="Doc.Keywords" />
        <rdf:String>opengl</rdf:String>
      </rdfq:contains>

      <rdfq:contains>
        <rdfq:Property name="Doc.Comments" />
        <rdf:String>opengl</rdf:String>
      </rdfq:contains>

      <rdfq:contains>
        <rdfq:Property name="File.Content" />
        <rdf:String>opengl</rdf:String>
      </rdfq:contains>
 
    </rdfq:or>

  </rdfq:and>
</rdfq:Condition>


(yes, 'and' does nothing there... I also tried without)

It acts like whether 'OR' is seen as 'AND'.



Im afraid the parser checking of rdf query is not as good as it could be.

It could be worst... :-)



Laurent.

Attachment: end-operator-not-handled.diff
Description: Text Data



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]