Menu

Blazegraph full text search with total count

Help
Didac
2017-09-07
2017-09-07
  • Didac

    Didac - 2017-09-07

    In SPARQL I can perform the following query in order to retrieve the fields and the total count in one query result (I know it can be more optimal with a WITH clause where to store the query, but it is not compatible with SPARQL):

    SELECT  ?total ?s
    WHERE
      { 
        { SELECT  (COUNT(?s) AS ?total)
          WHERE
            { ?s  <https://some/predicate/for/var1>  ?var1 ;
                  <https://some/predicate/for/var1>  ?var2
              FILTER ( ( ?var1 = "something" ) && ( ?var2 = "something2" ) )
            }
        }
        { SELECT  ?s
          WHERE
            { ?s  <https://some/predicate/for/var1>  ?var1 ;
               <https://some/predicate/for/var1>  ?var2
           FILTER ( ( ?var1 = "something" ) && ( ?var2 = "something2" ) )
            }
       LIMIT   3
      }
     }
    

    Which returns something like this (s fields matched the specific predicate and filter I provided on the query):

    +-------+----------------------------------------+
    | total |                   s                    |
    +-------+----------------------------------------+
    |   150 | http://the/path/to/the/subject         |
    |   150 | http://the/path/to/another/subject     |
    |   150 | http://the/path/to/yet/another/subject |
    +-------+----------------------------------------+
    

    I want to do the same for full text search queries, which can be used as follows ?s bds:search “something” .
    However, composing a query with the same structure as the previous one, does not work:

    PREFIX  bds:  <http://www.bigdata.com/rdf/search#>
    SELECT  ?total ?s ?org
    WHERE
    {
    { SELECT  (COUNT(?s) AS ?total)
        WHERE{
              ?matchedValue
                        bds:search        "something" ;
                        bds:relevance     ?score ;
                        bds:rank          ?rank .
              ?s        ?matchedProperty  ?matchedValue
              FILTER ( ! isBlank(?s) )
        }
    }
    { SELECT  ?s ?matchedProperty ?score ?rank
        WHERE{
              ?matchedValue
                        bds:search        "something" ;
                        bds:relevance     ?score ;
                        bds:rank          ?rank .
              ?s        ?matchedProperty  ?matchedValue
              FILTER ( ! isBlank(?s) )
        }
        LIMIT 10 
     }
    }
    

    Even though, those subqueries return the correct result separately.

     
  • Didac

    Didac - 2017-09-07

    I see. It is related to the bug: https://jira.blazegraph.com/browse/BLZG-1198
    There is a plan on fixing that?

     

    Last edit: Didac 2017-09-07

Log in to post a comment.