GrapdDB query with json-LD output - json-ld

is it possible to use GrapdDB to create a curl SPARQL query with json-LD output (no export)?
Which parameter do I have to insert in the URL?
thank you in advance

In order to get results in JSON-LD format you should add the following to the URL:
Accept=application%2Fld%2Bjson
Please note that only DESCRIBE and CONSTRUCT queries support the JSON-LD format.

I think that you have to add a HTTP header and I don't think adding a query param will work. Eg:
curl -HAccept:application/ld+json http://localhost:7200/repositories/some/statements?query=CONSTRUCT...
Unfortunately, you can't specify a context or frame to be used for the output.

Related

How to get a Query object from solr query string

There are solr query strings available from the log ,and the intent is to analyze the query to find out number fqs ,terms etc. Is there any api/parser available in solr/lucene to parse the entire query string and get the terms used ,filters used ,languages used ,fields used etc. Looked at QueryParser provided by lucene ,but it doesn't seem to help.
Example simple query string:
q=*:*&facet.field=Language&facet=true&f.Language.facet.limit=101&rows=0&sort=score desc,DefaultRelevance desc&fl=xxNonexx&bmf=50&wt=xml
You can use the SolrRequestParsers.parseQueryString() method to convert the string into Solr Params. Here's a link to documentation for it.
Below is an example.
String queryString = "q=*:*&facet.field=Language&facet=true&f.Language.facet.limit=101&rows=0&sort=score desc,DefaultRelevance desc&fl=xxNonexx&bmf=50&wt=xml";
MultiMapSolrParams solrParams = SolrRequestParsers.parseQueryString(String);
The code resides in the solr-core library, so you may need to add it.
I think you're not really looking for a parser but for a way to debug your query. Fortunately Solr has a debug parameter that you can use for such purpose as explained here. For instance you can add to your query:
q=*:*&facet.field=Language&facet=true&f.Language.facet.limit=101&rows=0&sort=score desc,DefaultRelevance desc&fl=xxNonexx&bmf=50&debug=true&wt=xml

Retrieving raw status output from solr admin

I want to write a script to compare results from a DataImportHandler to earlier results in an ETL process. The url I use in solr is:
http://HOSTNAME:PORT/solr/#/CORENAME/dataimport//dataimport
The Raw Status-Output has a nice JSON output with the information I need (documents fetched, etc) but I can't find anyway to return just this JSON output. Is there some argument I can give the URL or something? As it is I can't parse the page for the info I need.
You could use the LukeRequestHandler to get the state of the index.
If you set numTerms=0 you get a minimal output, with last index time.
In order to get json output, you can append wt=json&json.nl=map to your SOLR request querystring.
You can get it with: http://<host>:<port>/solr/dataimport?command=status&wt=json
If you want a pretty-printed output, pipe the body of the response to python -mjson.tool

How to create multiple filter query in solr?

I want to create query that can search on my pdf and text document. i can create the single query for content_type but for both at the same time i don't know how fix it,
for example for searching on my pdf document i create :
http://localhost:8983/solr/file/select?q=*&fq=content_type:application/pdf
but for text/plain and application/pdf i create bellow queries but do not work:
q=flex&fq=content_type:application/pdf&text/plain
q=flex&fq=content_type:application/pdf&fq=content_type:text/plain
Try: fq=content_type:application/pdf OR content_type:text/plain
I believe the syntax ought to be:
http://localhost:8983/solr/file/select?q=flex&fq=content_type:(application/pdf OR text/plain)

Getting snippets in Solr

I'm running Solr + Nutch and need to get a snippet of each result. I tried setting hl to true in the query URL but I still get the same XML result (without snippets). Any ideas on how to get this done?
You need to specify the fields that you want highlight results returned for by passing field names to the hl.fl parameter in your query. Please see HighlightingParameters on the Solr Wiki for more details and examples.

How to export solr result into a text file?

I needs to export doc_id, all fields, socr, rank of one search result to evaluate the results. How can I do this in solr?
Solr provides you with a CSV Response writer, which will help you to export the results of solr in an csv file.
http://localhost:8983/solr/select?q=ipod&fl=id,cat,name,popularity,price,score&wt=csv
All the fields queried would be returned by Solr in proper format.
This has nothing to do with SOLR. When you make a SOLR query over http, then SOLR does the search and returns the results to you in your desired format. The default is XML but lots of people specify wt=json to get results in json format. If you want this result in a text file, then make your search client put it there.
In the browser, File -> Save As.
But most people who want this use curl as the client and use the -o option like this:
curl -o result1.xml 'http://solr.local:8080/solr/stuff/select?indent=on&version=2.2&q=fish&fq=&start=0&rows=10&fl=*%2Cscore&qt=&wt=&explainOther=&hl.fl='
Note the single quotes around the URL due to the use of & characters.
There is not a built in export function in Solr. The easiest way would be to query your Solr instance and evaluate the XML result. Check out Querying Data in the Solr Tutorial for details on how to query a result from Solr. In order to convert the result into a text file, I would recommend using one of the Solr Clients found on the Integrating Solr page in the Solr Wiki and then choose your programming language of choice to create the text file.

Resources