Get Accumulo column family from api? - java

Learning Accumulo at the moment and I noticed there wasn't a direct call that I found for figuring out the column family for an entry. I need data from an Accumulo table in the format of
for example:
{key:"XPZ-878-S12",
columns:[{name:"NAME",value:"FOO BAR"},
{name:"JOB",value:"ENGINEER"}
]
}
And these spots are where I am trying to take data from:
{key:"key value from table",
columns:[{name:"name of column family",value:"value from table"},
{name:"name of column family",value:"value from table"}
]
}
So obviously key and value are easy to get ahold of, but what I call the "name" is extremely important to me as well, aka the column family name.

Yes it is possible. For example take a look at this:
for (Entry<Key, Value> entry : scan) {
Text key = entry.getKey().getRow();
Value val = entry.getValue();
returnVal.append("KEY" + key + " " + entry.getKey().getColumnFamily() + ": " + val + "\n");
}
The solution being for whatever entry you are looking at do entry.getKey().getColumnFamily()

Related

Spring data elasticsearch to create index dynamically based on request parameter, percolator support and create index via Elasticsearch Operations

I read through https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/#reference to begin with
My requirements
I want to use percolator. Is there any support for it in spring data elasticsearch? I don't see any in the above link although I understand that percolating is same as indexing (technically from using spring data elasticsearch's perspective). So I can use the indexing part of spring data elasticsearch but just checking if there are any that are specific to percolator.
I want to create an index dynamically. I do understand I can achieve that using SpEL template expression as mentioned in https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/#elasticsearch.mapping.meta-model.annotations but my case is slightly different, I will get the index name via the RequestParam as part of the API call. So this means as of my knowledge I cannot use SpEL or try something like https://stackoverflow.com/a/33520421/4068218
I see I can use ElasticsearchOperations or ElasticsearchRepository to create Index. Because of #2 (i.e index name via request parameter) I think ElasticsearchOperations better suits but I see IndexOperations facilitating createMapping, createSettings but not both together. I see putMapping too but I dont see anything that says both mapping and settings. The reason I want both is I want to create something like below to begin with
"settings" : {
"index" : {
"number_of_shards" : 1,
"number_of_replicas" : 0
}
},
"mappings": {
"properties": {
"message": {
"type": "text"
},
"query": {
"type": "percolator"
}
}
}
Bottom line :- How do I create an index (name of the index will be dynamic via request param) with mappings, settings using ElasticsearchOperations?
Any lead/help is much appreciated
First of all thank you very much #P.J.Meisch. Upvoted both your comments as a token of gratitude.
Below worked for me. Below might help others in future
Document mapping = Document.create().fromJson("{\n" +
"\n" +
" \"properties\": {\n" +
" \"message\": {\n" +
" \"type\": \"text\"\n" +
" },\n" +
" \"query\": {\n" +
" \"type\": \"percolator\"\n" +
" }\n" +
" }\n" +
"\n" +
"}");
Map<String, Object> settings = ImmutableMap.of( "number_of_shards" ,2,"number_of_replicas",1);
elasticsearchOperations.indexOps(IndexCoordinates.of("whatever-indexname-you-need")).create(settings,mapping);

Impossible to load data set[country_name] due to the following errors the paramerter has no value[par_country];

Step 1
I have created a Dataset which has parametric query
select city from country where country=$P{par_country}
I have added the attributes and on preivew it is working fine.
Step 2
Now i have created a LOV(List of values) with query
select cust_country from country
and on Testing it is giving me all the countries
Step 3
Added that LOV to AD(Analyical Drivers)
Step 4
Create a new cockpit with Data source created and then select a pie chart and i am getting this error
You have to set the parameters at the "filters editor" (funnel icon) when you are edditing the cockpit. It shows a list with the parameters of the dataset, and you can set the default values, etc.
That's the theory... but my parameter's list its empty, so i can't do nothing with the dataset parameters...
After spending days on this finally this has worked for me
I have made the changes by follwing this link https://www.spagoworld.org/jforum/posts/list/4272.page with some additional changes.
in below files:
1.SpagoBICockpitEngine/WebContent/js/src/ext4/sbi/cockpit/MainPanel.js
on first row function onShowFilterEditorWizard
*
config.stores = Sbi.storeManager.getStoreIds();
Sbi.trace("[MainPanel.onShowAssociationEditorWizard]: config.stores is equal to [" + Sbi.toSource(config.stores) + "]");
and uncomment the same lines in onShowFontEditorWizard method.
2.SpagoBICockpitEngine/js/src/ext4/sbi/widgets/grid/InMemoryPagingGridPanel.js
Row 96 in function loadStore, comment line as this:
//this.store.loadPage(1);
i have used javascript to add string parameter.
Query:select country,cnt from country_duns PLACEHOLDER_COUNTRY
and in edit scrpit
country = parameters.get('par_country');
if (country == null) {
placeholder = " ";
}
else {
placeholder = "where country = '" + country + "'";
}
query = query.replace("PLACEHOLDER_COUNTRY", placeholder);
parameter is par_country of string type

How to list AWS S3 objects and versions in a versioned bucket using Java

I would like retrieve a list of all objects in a versioned bucket along with their versions in a list similar to how the AWS S3 Console does it:
I am able to list objects in a non-versioned bucket using the advice from this SO question. However, it is not all that clear how to list them along with version IDs as S3ObjectSummary contains no versioning information. It would seem cumbersome to make separate calls to versioning methods and then try to put them together with the information contained within an S3ObjectSummary
This looks like the closest answer I could find so far:
http://docs.aws.amazon.com/AmazonS3/latest/dev/list-obj-version-enabled-bucket.html
The relevant code snippet is here:
ListVersionsRequest request = new ListVersionsRequest()
.withBucketName(bucketName)
.withMaxResults(2);
// you can specify .withPrefix to obtain version list for a specific object or objects with
// the specified key prefix.
VersionListing versionListing;
do {
versionListing = s3client.listVersions(request);
for (S3VersionSummary objectSummary :
versionListing.getVersionSummaries()) {
System.out.println(" - " + objectSummary.getKey() + " " +
"(size = " + objectSummary.getSize() + ")" +
"(versionID= " + objectSummary.getVersionId() + ")");
}
request.setKeyMarker(versionListing.getNextKeyMarker());
request.setVersionIdMarker(versionListing.getNextVersionIdMarker());
} while (versionListing.isTruncated());

combining parameters from an array field in Solrj

I have data index in Solr. One parameter is an array and looks like this:
<arr name="sm_vid_Code_of_Federal_Regulations">
<str>Section 1.13</str>
<str>Subpart A</str>
<str>Part 1</str>
<str>Subtitle A</str>
<str>Title 7</str>
</arr>
I need to restrict the results using two or more of these fields.
I tried the following but it does not seem to be working correctly:
params.set("fq", "(sm_vid_Code_of_Federal_Regulations:\"Part " + "1" +"\")" + " OR "
+ "(sm_vid_Code_of_Federal_Regulations:\"Title " + "7" +"\")");
Is this the right approach to combine elements from a field array?
Turns out that I should use the class SolrQuery and the method addField.
So the correct code will be:
SolrQuery query = new SolrQuery();
query.addFilterQuery("(sm_vid_Code_of_Federal_Regulations:\"Title " + "7" +"\")",
"(sm_vid_Code_of_Federal_Regulations:\"Part " + "1" +"\")");
You can add apply multiple query filters using the addFilterQuery method.
I am very grateful to the anonymous person who wrote the fantastic Solr tutorial:http://www.solrtutorial.com/solrj-tutorial.html

Get all values from LDAP entries (with same names) and store them in Lotus Notes with Java

I am retrieving account information from an LDAP/AD via JNDI from an agent in Lotus Notes. That works just fine. My problem are the atrributes/values with equal names e.g. there are ObjectClass and ObjectType which are availible multiple times in the entry. I want to store the values as a multitext entry in LotusNotes with the following code
for (NamingEnumeration ae = atts.getAll(); ae.hasMore();) {
Attribute attr = (Attribute) ae.next();
Item mItem = newDoc.getFirstItem(fPre + "_" + attr.getID());
if(mItem == null){
newDoc.replaceItemValue(fPre + "_" + attr.getID(), attr.get());
}else{
mItem.appendToTextList("" + attr.get());
}
}
But I only get always one value. So do I accessing the entry in the LDAP/AD the wrong way or is the storing in Notes wrong (is not possible to access the Item without saving, like it is possible with LotusScript)?
Thanks
Armin

Categories