Use reactivesearch to query multiple indices - reactivesearch

I realize that one can use ReactiveBase to setup a connection to an index and then, use the components to query and return information from that index.
Is there a way to bind to multiple indices and search on a field across them or return results that are a 'merge' of fields from these multiple indices?

In order to query multiple indices ReactiveBase can accept comma separated values in the app prop. Example:
<ReactiveBase
app="index1,index2"
...
>
...
</ReactiveBase>

thanks to siddharthlatest, it is possible by providing multiple comma-separated indices - reference.
It has been reflected in the ReactiveBase documentation as well.

Related

Using #query on CrudRepository(Spring data jdbc) with table join

I am trying spring data jdbc with #query and I met a question: If I have a query that joins 2
tables like this:
#Query("select a.*, b.* from master a, detail b where b.master_id=a.id and a.id=:id")
How do I get the response?
The official Spring Data JDBC, References, and Aggregates didn't give any hint on it.
Any suggestion?
You have multiple options:
Use the default RowMapper
Use as the return type a class (or a collection of that class) that has properties for all the fields you are selecting.
This will return a single element for each row.
Since you are referring to the two tables as master and detail you probably don't want that in this case.
Use a custom RowMapper
The #Query annotation allows you to specify your own rowMapperClass which will get instantiated and passed to a NamedParameterJdbcTemplate together with your query.
Again this will result in on result element per row selected and therefore probably isn't what you want.
Use a custom ResultSetExtractor
This can be again specified in the #Query annotation.
And allows you to construct the result in an arbitrary way.
See the documentation for ResultSetExtractor for more details.
Remark: If you are using a ResultSetExtractor to create a single Master with multiple Detail instances from multiple rows of your query result make sure to add an ORDER BY master.id. Otherwise the order of rows is likely as desired but actually not guaranteed.

Organize alternative names (nicknames, aliases) in neo4j

Say you have some nodes in your model that may go by multiple alternative names, but all the names refer to the same object.
For example, you may want to be able to query the "World" node by using name "World" in one context, whereas in different context you want to find the same node quickly also by the name "Global".
Is it optimal to organize this information in the form of string array property aliases like this? :
If you add World to your aliases you can use the legacy node_auto_index to index that aliases field
which will index each value individually and the query it with
Start n=node:node_auto_index(aliases="Global")
return n
I think you could use Lucene for that.
You could index the same property several times with different names.
You can then query the index in the way you want through Java APIs or Cypher.
For instance:
START n = node:myIndex(myProperty="ALIAS_1"),
m = node:myIndex(myProperty="ALIAS_2")
[...]

I saw author/media$credit tag using list, is it possible multiple authors on same channel?

Example, http://gdata.youtube.com/feeds/api/users/google/uploads?v=2&start-index=1&max-results=50&alt=json,
"author":[{"name":{"$t":"Google"},"uri":{"$t":"http://gdata.youtube.com/feeds/api/users/Google"},"yt$userId":{"$t":"K8sQmJBp8GCxrOtXWBpyEA"}}]
"media$credit":[{"$t":"google","role":"uploader","scheme":"urn:youtube","yt$display":"Google","yt$type":"partner"}]
Both author and media$credit tag is a list, so is it possible index 1 on the list? If it's impossible, why list?
Thanks
I'm not aware of any scenario in which there would be multiple values returned for those fields. I can't say for certain why it's a list and not a single element.

Informix - Aggregating list of values into comma-delimited string

Is there a way to convert a list of values into a comma-delimited string in Informix? For example, I have the following query as a subselect:
SELECT [State] From States
I would like to convert all the values from that select into a comma-separated list.
Can I do that in informix?
I think the answer you need is given in these questions: SO 715350, SO 489081. It shows how to create and use a GROUP_CONCAT() aggregate that will do exactly what you want. The functionality is otherwise not available - that is, you have to add it to Informix, but it can (fairly) easily be added.

How to get the uncommon elements of two linked list?

Given two linked lists of integers. I was asked to return a linked list which contains the non-common elements. I know how to do it in O(n^2), any way to do it in O(n)?
Use a hash table.
Iterate through the first linked list, entering the values you come across into a hash table.
Iterate through the second linked list, adding any element not found into the hash table into your list of non-common elements.
This solution should be O(n), assuming no collisions in the hash table.
create a new empty list. have a hash table and populate it with elements of both lists. complexity n. then iterate over each list sequentially and while iterating, put those elements in the new list which are not present in the hash table. complexity n. overall complexity=n
If they're unsorted, then I don't believe it is possible to get better than O(n^2). However, you can do better by sorting them... you can sort in reasonably fast time, and then get something like O(nlogn) (I'm not certain that's what it would be, but I think it can be that fast if you use the right algorithm).

Resources