how to get term vectors by using Elasticsearch Hadoop - scala

I'm using ElasticSearch-Hadoop API. And I was trying to get _mtermvector by using the following Spark code:
val query= """_mtermvectors {
"ids" : ["1256"],
"parameters": {
"fields": [
"tname"
],
"term_statistics": true
}
}"""
var idRdd = sparkContext.esRDD("uindex/type1",query)
It didn't work, any ideas please, appreciate!

You can't use endpoints (like _mtermvectors) which are part of the document API's with ES-Hadoop. Only queries which belongs to the query API's, query DSL or external resource are allowed.
Hope that it helps.

Related

Comments on queries through MongoDB .Net driver?

Reading up on MongoDB performance troubleshooting I see that MongoDB supports appending comments on queries. We thought we might add our correlationid to queries so we can correlate which features result in slow queries and/or check whether when we discover slowness in a feature if we can spot some slowness in mongodb.
How can we add comments to queries and/or commands through the .net driver?
How can we add comments to queries and/or commands through the .net driver?
You can utilise FindOptions.Comment to set a comment on a query or a command. For example:
var collection = database.GetCollection<MyObject>("collectionName");
var filter = Builders<MyObject>.Filter.Eq("Name", "Foo");
FindOptions myFindOptions = new FindOptions();
myFindOptions.Comment = "THIS IS FEATURE XYZ";
var cursor = collection.Find<MyObject>(filter, myFindOptions).ToList();
Once you set the database profiler i.e. via db.setProfilingLevel(), you can then query the (database).system.profile collection to find it. For example:
db.system.profile.find({
ns:"dbName.collectionName",
"command.comment":"THIS IS FEATURE XYZ"
});
// Example result:
{
"op": "query",
"ns": "dbName.collectionName",
"command": {
"find": "collectionName",
"filter": {
"Name": "Foo"
},
"comment": "THIS IS FROM FEATURE XYZ",
"$db": "dbName",
"lsid": {
"id": UUID("6b722166-f50b-409c-85f0-2711633baff2"))
}
},
....
}
The above .NET/C# code snippet is written using MongoDB .NET/C# driver v2.9.3.

How to filter by count on gremlin map (OrientDB)

I have a somewhat similar business problem to - Gremlin filter by count
, but I'm running on OrientDB 3.0.16
This query:
g.V().hasLabel('skill').
groupCount()
Returns from OrientDB, as expected:
{
"result": [
{
"com": 1,
"netcompactframework": 1,
"netremoting": 2,
"netframework": 3,
"net": 1,
"netclr": 1
}
],
"elapsedMs": 18
}
I tried to apply an unfold and where filter after it:
g.V().hasLabel('skill').
groupCount().
unfold().
where(select(values).is(gt(1)))
But I get an error:
{
"errors": [
{
"reason": 501,
"code": 501,
"content": "java.lang.UnsupportedOperationException: Cannot convert netremoting=2 - class java.util.HashMap$Node to JSON"
}
]
}
It seems that problem is with unfold() as OrientDB is trying to convert the map entry string into JSON and fails
Any ideas?
Is this an OrientDB specific issue? Maybe there is another way to perform the same logic in gremlin?
That looks like a serialization error of some sort, but I'm not sure of the circumstance under which you are operating to get that problem. When you unfold() a Map, it gets converted to Java Map.Entry and returning that seems to be a problem for the serializer which along the way encounters the internal class HashMap$Node. I think you can work around this problem by folding back to a Map:
g.V().hasLabel('skill').
groupCount().
unfold().
where(select(values).is(gt(1))).
group().
by(keys).
by(select(values))
I would be curious to know what circumstances cause you to get that error. Standard GraphSON serializers in Gremlin Server should be able to handle HashMap$Node so it's curious that you'd be getting this problem at all.

Any default APIs in Dolibarr for creating sales order records?

Dolibarr has a module for restful APIs.
The API explorer seems to show all the CRUD tasks for each module like orders, stock and customer.
But to CREATE a record, the sample VALUE for the POST method shows as:
{
"request_data": [
"string"
]
}
What are the specific field attributes that should go in here?
Where can I look up the field requirements?
You should take a look at the attributes of the Commande class:
https://github.com/Dolibarr/dolibarr/blob/develop/htdocs/commande/class/commande.class.php
The object should be something like this :
{
"date_commande" : "0000-00-00 00:00:00",
"date_livraison" : "0000-00-00 00:00:00",
"attribute3": "and so on"
}
When you need a parameter like
{ "request_data": [ "string" ] } for a POST API, all you have to do is to call the similar API to get a record (so the same API with the GET method). The result can be cut and paste to be used to create a new record (just change the id and ref in the answer retreived by the GET).

How to query Cloudant documents for a specific field

I am new to Cloudant and I need to do a simple query on a specific document field. My documents have the following structure and I need to get only the documents with status=SIGNED
{
"_id": "3ddb4058f3b24a7a9c585f997e30ff78",
"_rev": "3-757c82c48f4e7c333911be6859aff74e",
"fileName": "Generali Architects",
"status": "SIGNED",
"user": "italy",
"_attachments": {
"Generali Architects": {
"content_type": "application/pdf",
"revpos": 3,
"digest": "md5-9hqSif7CzQ2yvKxSSbj+dw==",
"length": 323653,
"stub": true
}
}
}
Reading Cloudant documentation I created the following Design Document with a related view which returns exactly what I expected
Then from my Java application I use the following code
String cloudantView = "_design/signedDocs/status-signed-iew";
List<SignDocDocument> docs =
db.view(cloudantView).includeDocs(true).query(SignDocDocument.class);
which always returns me "org.lightcouch.NoDocumentException: Object Not Found"
Any idea which kind of mistake I am making here?
Thank you very much
Is it the typo in "_design/signedDocs/status-signed-iew"; e.g. that should be "_design/signedDocs/status-signed-view"; (depending on how your java library works...).
Always worth checking the view by direct access in your browser, too, just to make sure it's returning the expected data.

Neo4j cypher query on ID returns no values via REST but does via Data Browser

Neo4j version 1.8.M06
The following query executed in the Data Browser on the web management interface returns a value for the Forename property:
start n=node(*) where ID(n)=147 return n.Forename
However the same query posted using the REST API
{
"query" :
"start n=node(*) where ID(n)={id} return n.Forename",
"params" :
{"id" : "147"}
}
Returns:
{
"columns" : [ "n.Forename" ],
"data" : [ ]
}
Any idea what I'm doing wrong?
You don't want quotes around 147 in the REST call.
Also, maybe it's because of your simplification, but I'm pretty sure you should really be doing start n=node({id}) instead, for optimum performance. Not sure if it optimizes that sort of thing out.