Calling Stored Procedure from Solr

calling stored procedure from solr

For me it works like this:

<dataSource name="ds-1" type="JdbcDataSource" driver="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="jdbc:sqlserver://10.0.2.47;databaseName=dbname" user="username" password="password" 
responseBuffering="adaptive" batchSize="0" autoCommit="false" />
<entity name="item" dataSource="ds-1" query="[sp_StuffDataImportHandler]"></entity>

But this only works if the stored procedure contains a simple SELECT query.

If I declare some variables or temporrary tables before the query that will return the results then the import fails, giving me the same exception that you get.

LATER EDIT

I managed to make it work with more complex queries in the Stored Procedure. by adding
SET NOCOUNT ON; at the beginning of the stored procedure.

Apache Solr: How to make execution of a query in a sub-entity dependent on a field from the main entity

Seems like writing more complex SQL in data-config is not possible so I ended up calling a stored procedure with parameters. In the stored procedure I can write more complex logic. Data-config sample:

<entity name="categories_lvl_0" dataSource="ds-sql" query="[_getSolrProductCategoriesLvl0] '${searchobject.objecttype}', '${searchobject.id}'"> 
</entity>

More details here: calling stored procedure from solr

Solr dataimporthandler use storedProcedure in deltaImportQuery

Short answer would be yes.

Have you tried / got any errors? If yes, please take a look at : calling stored procedure from solr

You may want to add SET NOCOUNT ON; at the beginning of the stored procedure.

Dynamic TableName SOLR data import handler

I think you could achieve this by:

  1. using an stored procedure. You can call a sp from DIH as seen here
  2. inside the stored procedure, you can do the table lookup as needed, and then return the results from the real query.

Depending on how good you are with MSSql-s SQL, you might be able to just put everything into a single SQL query and use that directly in DIH, but not sure about that.

Checking health/availability of underlying stored procedure before calling an API from Karate

You seem to be asking the same question again: https://stackoverflow.com/a/56839037/143475

The short answer is - use Java interop and you can do anything in Karate: https://github.com/intuit/karate#calling-java

If you are doing normal API testing, you don't need to use Java and many teams are happy this way - just making HTTP requests. To do what you are asking, just see the above link, and there is plenty of material on this. If you can't figure this out from the documentation and if you have challenges writing Java code - then maye Karate is not for you - and you need to look for some other alternative.

Solr : Importing data with single SP call

In your import configuration for the Data Import Handler, you can add transformer="RegexTransformer" to your <entity> definition, and then use splitBy="," on the field to split it into multiple values.

<entity name="foo" transformer="RegexTransformer" .... >
...
<field column="associated_folder" splitBy="," />
</entity>

See the documentation for RegexTransformer.



Related Topics



Leave a reply



Submit