I'm trying to execute several RQL commands in a single request to server, without much success I may add. I have tried r.union, but it only works with sequences. What I really want:
[r.db(..).table(..).get(id1).delete(),
r.db(..).table(..).get(id2).delete(),
r.db(..).table(..).insert(...)].run_all_at_once
Is there any way to do this?
Thanks!
You can also use do
r.do(
r.table('test').insert({value1: "Hey"}),
r.table('test').insert({value2: "Ho"})
).run(conn);
The queries are evaluated from last to first
The response will be the last query's result
You can do
r.expr( [r.db(...).table(...).get(id1).delete(),
r.db(...).table(...).get(id1).delete(),
r.db(...).table(...).insert(...) ] ).run(conn)
Note that the method delete doesn't get an argument.
Related
I wonder how to make eXide to return more than 10 results. No matter how I query the database, it is not possible to get more. Is there some special rule in $EXIST_HOME or so?
I use eXist-db 3.0.RC1.
One way is to wrap your query in an element.
<results>{... your query here ...}</results>
Wrapping results is the way to go, but if you wish, you can edit /db/apps/eXide/resources/scripts/eXide.min.js, changing "10" in "q=n+10-1" to some other number.
I have two cq page and I want to retrive these two using jcr:title property using XPATH. The below query is working fine for single.
/jcr:root/content/test//element(*, cq:Page)[((jcr:like(jcr:content/#jcr:title, dell)))]
But I want to excuate it for multiple items. I have tried with following option but it is not working
/jcr:root/content/test//element(*, cq:Page)[((jcr:like(jcr:content/#jcr:title, [dell,samusng])))]
Could anyone help me to write xpath query?
As rakhi4110 already mentioned in the comment, you can combine multiple where clauses with an or just like in SQL. Though I think you either want exact matches or use jcr:containts instead of jcr:like.
Exact match:
/jcr:root/content/test//element(*, cq:Page) [jcr:content/#jcr:title='dell' or jcr:content/#jcr:title='samsung']
Contains:
/jcr:root/content/test//element(*, cq:Page) [jcr:contains(jcr:content/#jcr:title, 'dell') or jcr:contains(jcr:content/#jcr:title, 'samsung')]
Or if you really want to use jcr:like which, as in SQL, uses % for wildcard:
/jcr:root/content/test//element(*, cq:Page) [jcr:like(jcr:content/#jcr:title, '%dell%') or jcr:like(jcr:content/#jcr:title, '%samsung%')]
I want to see number of affected rows of my target table. For that, I can write a shell script in which I pass a parameter as $PM#numAffectedRows. However, if my target table name is parameterized and I want to pass that in the same shell, how can I do that?
Eg.
$ParamTgtTable=myTable
When I pass $PM'$ParamTgtTable'#numAffectedRows in the shell script, it echos myTable#numAffectedRows. If I pass the same without the quote as $PM$ParamTgtTable#numAffectedRows, I get $ParamTgtTable#numAffectedRows as my output.
Is there any workaround for this? Appreciate your help on this.
pass 2 parameters seperately like
$ParamTgtTable=myTable
$PM#numAffectedRows=your_count
now create a third parameter as X=$ParamTgtTable$PM#numAffectedRows
if didnt work try using single quotes (i dont have access to UNIX to test right now)
I am using this Eloquent raw query to fetch some search results combining both caption and tags column. my code goes like this
$term="Test";
$clips= \Clip::whereRaw("caption like '%?%' OR tags like '%?%' ", array($term,$term))->get();
dd($clips);
but using this I am not able to get results as the dump shows no results, where as using below code I am able to get results:
$term="Test";
$clips= \Clip::whereRaw("caption like '%$term%' OR tags like '%$term%' ")->get();
dd($clips);
and dump shows all 5 results which are expected. What am I doing wrong in first case.
If you use prepared statements, you should use a ? and nothing else. If you're adding quotes yourself, you should not be using prepared statements. So let the prepared statement take care of the quotes and add the %-sign to the variable you are inserting into the prepared statement.
$term="Test";
$clips= \Clip::whereRaw("caption like ? OR tags like ? ", array('%'.$term.'%','%'.$term.'%'))->get();
dd($clips);
By the way, you could also do this without a raw where..
$term="Test";
$clips=\Clip::where("caption","like","%".$term."%")->orWhere("tags","like","%".$term."%")->get();
dd($clips);
... and personally I would even prefer to use a scope for these kind of things.
How would I use SolrNet to execute a GREATER THAN/LESS THAN query?
Example:
My documents have a field called "minimumDays" and I only want to return docs where that field is LESS THAN OR EQUAL TO the number I pass into the query.
I currently have this, but am not sure it's correct.
int requestedDays = 3;
var minimumNightsQuery = new SolrQueryByRange<int>("minimumDays", 0, requestedDays, true);
Am I on the right track?
The second part here is if there is some way to better understand the query that is being passed into Solr from SolrNet? Debugging value or something where I can inspect the "q" variable for instance.
Thanks again for your help
You can use SolrQueryByRange for the first part of your question. Your code does look good. debugging your query and results might help. I have found that SolrNet does some odd things. - http://code.google.com/p/solrnet/wiki/Facets#Arbitrary_facet_queries
For the second part, You can intercept the ISolrConnection and put in your own in between. For a good start check this out: http://code.google.com/p/solrnet/source/browse/trunk/SampleSolrApp/LoggingConnection.cs?r=513
I have one that logs the query and the results, and if a config setting is on it appends the debug param and logs that result also. Its great info to have.... and one of the only ways to get it.