How to transplant an index into a solr core - java

My situation is this:
I have an index that has been generated by an entirely different app and I want to transplant/expose it from solr.
I can easily do that, but the problem now is I can't query on any of the fields. I just get empty {}
I modified the schema to include the fields from the documents transplanted and it doesn't seem to have made a difference.
When I do a q=*:* I can see all the documents so I know the info is there. This has to be easy. I am just missing it.
Would anyone like to give me an education?
Document example:
"docs": [
{
"code": "A000",
"description": "Cholera due to Vibrio cholerae 01, biovar cholerae",
"version": "10",
"concepts": [
"cholera",
"cholera-due to biovar cholera",
"cholera-due to vibrio cholerae 01",
"infectious diseases",
"intestinal infectious diseases"
],
"tags": [
"biovar",
"cholera",
"cholerae",
"diseases",
"infectious",
"intestinal",
"vibrio"
],
"category": "A00",
"etiology": "0"
},
]

Related

Can We Work with Multiple Json Format from Single Topic using Single Stream App in Apache Kafka?

I have 2 json format in same kafka topic
1st JSON
{
"id": 123,
"name": "name",
"values": [
"one": 1,
"two": 2,
"three": 3,
"four": 4
]
}
2nd JSON
{
"id": 8,
"title": "Microsoft Surface Laptop 4",
"description": "Style and speed. Stand out on ...",
"price": 1499,
"discountPercentage": 10.23,
"rating": 4.43,
"stock": 68,
"brand": "Microsoft Surface",
"category": "laptops",
"thumbnail": "https://dummyjson.com/image/i/products/8/thumbnail.jpg",
"images": [
"https://dummyjson.com/image/i/products/8/1.jpg",
"https://dummyjson.com/image/i/products/8/2.jpg",
"https://dummyjson.com/image/i/products/8/3.jpg",
"https://dummyjson.com/image/i/products/8/4.jpg",
"https://dummyjson.com/image/i/products/8/thumbnail.jpg"
]
}
I want to perform some transformation on these two JSON's with single Stream application and produce output in different topics.
Is it possible to work with single stream app ? if yes, then how?
Iam currently using JAVA for stream application
Sure, you can consume the data as generic JsonObject/JsonNode classes using builtin JSON deserializer, then check for specific fields in a filter/branch operator before parsing to a specific POJO.
Or you can use String Serde, pass strings to JSON parsers, and do the same.
Alternatively, use two different topics and join events based on the ID field, for example

Get root element using jsonpath based on sub elements condition

I am working with the Jayway JsonPath library to obtain the correct 'id' from below JSON where my phoneNumbers type is 'iPhone'.
In general, I would like to know how to find something from the root element of a block when a specific condition is specified in the sub-JSON objects.
I tried below expressions that select the block associated with iPhone type and also a list of ids respectively, but I am not able to get to the root element id belonging to the JSON object where my phone type is iPhone. Can someone please guide me? I need to get the id as 1 for this question.
To get the list of ids: $[*].id
To get the json object corresponding to iPhone type: $[*].phoneNumbers[?(#.type=='iPhone')]
[
{
"id": "1",
"phoneNumbers": [
{
"type": "iPhone",
"number": "0123-4567-8888"
},
{
"type": "home",
"number": "0123-4567-8910"
}
]
},
{
"id": "2",
"phoneNumbers": [
{
"type": "x",
"number": "0123-4567-8888"
},
{
"type": "y",
"number": "0123-4567-8910"
}
]
}
]
I think you want your expression to look deeper.
First, find the objects that have an iPhone in the phone numbers list. Then just select the IDs.
Try $[?(#.phoneNumbers[*].type=="iPhone")].id.
Edit
It looks like the Java JsonPath library (I think you're using this) supports a number of functions. It doesn't list a contains(), but you might try the anyof operator:
$[?(#.phoneNumbers[*].type anyof ["iPhone"])].id
Note that this is definitely implementation-specific and will likely not work with any other library.

ElasticSearch 5.6 is there a way to modify ES search response?

Let's say I have a search response like
"hits": [
{
"_index": "customer",
"_type": "doc",
"_id": "5",
"_score": 1,
"_source": {
"name": "TEST1",
"surname": "Soanems1"
}
},
I want to be able to modify the data before the user gets the response. Let's say the "name" field has a value of "TEST1" and I want the data at rest to stay "TEST1" but I want the user to see a different value, for example, "TEST12345". Is there a way to do it?
Is there a way to create a custom plugin that does this transformation for me? (there are some not trivial transformations that I want to do to the response)

Good way to store many nested JSON objects and arrays as data structure in Android SQLite?

Considering the below JSON, what would be the best way to store this into SQLite?
I am already parsing this with Gson, but wondering what would be a pain-free way to store this into SQLite and be able to retrieve it with no parsing issues.
I am already storing the desc, deposit objects as a HashMaps. My issue is the lease object. What would be an elegant way to store the leasees array?
Should I just create another Leasee object? And then serialize the ArrayList into a Blob for storage into the database?
{
"name": "1",
"desc": {
"country": "1",
"city": "1",
"postal": "1",
"street": "1",
"substreet": "1",
"year": 1,
"sqm": 1
},
"owner": [
"1"
],
"manager": [
"1"
],
"lease": {
"leasee": [
{
"userId": "1",
"start": {
"$date": 1420070400000
},
"end": {
"$date": 1420070400000
}
}
],
"expire": {
"$date": 1420070400000
},
"percentIncrease": 1,
"dueDate": 1
},
"deposit": {
"bank": "China Construction Bank",
"description": "Personal Bank Account USA"
}
}
Storing everything in a BLOB ignores the benefit that a DB provides.
You have much of a relational database structure already described (however loosely) in the JSON:
Properties table with location and description info.
Persons table with names and contacts.
Roles table relating Properties and Persons (residents, managers, owners, service providers).
Leases table with terms related to Properties and Persons.
Payments table with payment info related to Leases.
You can manually write in the primary keys in your JSON, taking care to match those relationships between tables, then insert the resulting rows by processing that modified JSON. Here's a link to SQLite doc on using INSERT with auto increment.

How to return a list of married people using MQL query

I'm quite new with freebase, and I was wondering if it's possible to use a query to return people who are married. I've looked at alot of the properties I could use in freebase, but they only show how to find people married to a specific person. Rather, I'd want to find people who are married, or have been in a marriage in the past.
After a while playing round with the properties in freebase, I tried adding on the following to my freebase query.
"spouse_s": [{
"spouse": []
}]
And it works perfectly, it removes any person who doesn't have a spouse_s property. For example, the MQL query below returns "Jaden Smith" as on of its topics:
[{
"type": "/people/person",
"limit": 10,
"name": null,
"name~=": "Jaden",
"profession": "actor",
}]
However, adding in the spouse_s property removes Jaden from the list of results, as Jaden Smith has never been married.
[{
"type": "/people/person",
"limit": 10,
"name": null,
"name~=": "Jaden",
"profession": "actor",
"spouse_s": [{
"spouse": []
}]
}]

Categories

Resources