Question

I have a file containing a huuuge query (without parameters) so i'm wondering if it is possible to load the "query" attribute directly from that file instead of copying and pasting manually.

The query in the file is well indented and therefore more maintainable. Putting the whole command in the "query" attribute of the dih-config.xml requires to copy, paste and wrap in a single line all the stuff and I would like to avoid that.

Was it helpful?

Solution

AFAIK, that isn't possible (But I could be wrong!).

But in one of my implementations, we had a SQL query that was big enough and we ended up using a View to get this. Basically, create a view encapsulating the query.

There are a few advantages to this approach (IMHO):

  • You could alias the field names in the query and make use of the convention to map to SOLR schema (Solr field names could be same as Query column names).
  • You do not need to deploy SOLR if your query logic(not field selection) changes.
  • Your data-config is quite lean and does not hold any business logic.
  • It is easier to debug - a 'select * from ' would dump all the data that goes to DIH.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top