I am trying to implement a solr search for a project. Everything was fine so far, a first simple version worked. Now I try to import from a postgres data base where multiple columns should end up in the same field. My config:
<entity name="address" query="SELECT objectid, ags2, ags3, ags5, ags8, ags11, ags20, ags22, pt, stn, hnr_min, hnr_max, plz, ort, ortz, ot1, ot2 FROM variablen2018.ags22_tmp_solr LIMIT 10000;">
<field column="objectid" name="id" />
<field column="plz" name="plz" />
<field column="ort" name="ort" />
<field column="ortz" name="ort" />
<field column="ot1" name="ort" />
<field column="ot2" name="ort" />
<field column="ort" name="ort_res" />
<field column="stn" name="stn" />
<field column="stn" name="stn_res" />
<field column="ags2" name="ags2" />
<field column="ags3" name="ags3" />
<field column="ags5" name="ags5" />
<field column="ags8" name="ags8" />
<field column="ags11" name="ags11" />
<field column="ags20" name="ags20" />
<field column="ags22" name="ags22" />
<field column="pt" name="coord" />
<field column="hnr_min" name="hnr_min" />
<field column="hnr_max" name="hnr_max" />
</entity>
As you can see there are 4 columns from the DB (ort, ortz, ot1, ot2) going into one field (ort). Most of the times only one of the columns is populated at all, in which case the document is indexed normally. But when there are actually multiple entries the indexing of the document fails. The field is defined this way:
<field name="ort" type="text_de" uninvertible="true" indexed="true" required="true" stored="true"/>
DataImporthandler maps the result view of the query to a schema view and hence I don't think that you will be able to map multiple columns to one field. Instead you can assign each column to a new Solr field and then do a copy of them in your schema.
eg
<field name="ort" type="string" />
<field name="ortz" type="string" />
<field name="ot1" type="string" />
<field name="ot2" type="string" />
<field name="ortCombined" type="string" multiValued="true"/>
<copyField source="ort" dest="ortCombined" />
<copyField source="ortz" dest="ortCombined" />
<copyField source="ot1" dest="ortCombined" />
<copyField source="ot2" dest="ortCombined" />
Hope this helps !
you do it this way:
you concatenate all values into a single value in the Select:
select ...,ort||','||ortz||','||or1||','||ort2 AS ort_all FROM variablen2018.ags22_tmp_solr
and then split it into individual values when indexing into solr (this is done with RegexTransformer/splitBy)
< entity name="address" transformer="RegexTransformer"
...
< field column="ort_all" name="ort" splitBy=","/>
Note: inserted a space after < or the text does not show up here...
To watch out:
handle possible nulls, check concat_ws etc
handle possible , inside ort values (use another separator or replace , etc)
Related
I indexed 2M+ documents and when I request the last result order by name, the response is very slow (18s).
Is there a wy to optimize the sorting ?
My request :
http://localhost:8983/solr/items/select?&q=*:*&start=2274000&rows=100&sort=name_sort asc&fl=id,name
Below is the field definition in schema.xml file
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<!-- docValues are enabled by default for long type so we don't need to index the version field -->
<field name="_version_" type="plong" indexed="false" stored="false"/>
<field name="name" type="text_general" indexed="true" stored="true" multiValued="false" />
<field name="name_sort" type="string" indexed="true" stored="false" multiValued="false" />
I want to show the fields that i mentioned in the tree string when there are no records in my tree view instead of showing "Click to add a new Sample record."
<record model="ir.ui.view" id="sample_tree_view">
<field name="name">Sample</field>
<field name="model">sample.test</field>
<field name="arch" type="xml"
<tree string="Sample" default_order="name">
<field name="code" />
<field name="name" />
<field name="status" />
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="action_sample">
<field name="name">Sample</field>
<field name="res_model">sample.test</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click here to create a new sample Record.
</p>
</field>
</record>
Thanks in advance ..!
Please remove help from your defined action & check.
I have given editable bottom so i am getting default delete icon of odoo11. But i want to change it only to my module. How to change the delete icon to my own module ?
<field name="name"> Attachments</field>
<field name="model">attachments</field>
<field name="arch" type="xml">
<form string="Attachments">
<field name="line_ids" >
<tree string="Attachments" editable="bottom">
<field name="description" />
<field name="file_name" invisible="1" />
<field name="upload_file" filename="file_name" />
<button name ="download" icon ="gtk-go-down" type="object" />
</tree>
</field>
Thanks in Advance !
just add delete="false" in tree view
<field name="name">Attachments</field>
<field name="model">attachments</field>
<field name="arch" type="xml">
<form string="Attachments">
<field name="line_ids" >
<tree string="Attachments" editable="bottom" delete="false">
<field name="description" />
<field name="file_name" invisible="1" />
<field name="upload_file" filename="file_name" />
<button name ="download" icon ="gtk-go-down" type="object" />
</tree>
</field>
You can add delete="false" in tree tag
ex.
<tree string="Attachments" editable="bottom" delete="false">
<field name="description" />
<field name="file_name" invisible="1" />
<field name="upload_file" filename="file_name" />
<button name ="download" icon ="gtk-go-down" type="object" />
</tree>
I'm trying to integrate Solr-6.6.0 and Cassandra-3.10. I tried using JDBC of cassandra and I got to know that Cassandra JDBC does not support to the latest versions. Then, I came across Datastax Driver. So, right now I'm using Datastax cassandra-driver-core-3.1.4 as my java jar file.
solrconfig.xml
<requestHandler name="/dataimport" class="solr.DataImportHandler">
<lst name="defaults">
<str name="config">sample-data-config.xml</str>
</lst>
</requestHandler>
I added the above lines.
sample-data-config.xml
<dataConfig>
<dataSource type="JdbcDataSource" driver="com.datastax.driver.core.Connection" url="jdbc:cassandra://127.0.0.1:9042/demo" autoCommit="true"/>
<document name="content">
<entity name="test" query="SELECT id,org,name,dep,place,sal from tutor" autoCommit="true">
<field column="id" name="id" />
<field column="org" name="org" />
<field column="name" name="name" />
<field column="dep" name="dep" />
<field column="place" name="place" />
<field column="sal" name="sal" />
</entity>
</document>
</dataConfig>
where tutor is my table and demo is my keyspace.
manageschema.xml
<field name="org" type="string" indexed="true" stored="true" required="true" />
<field name="dep" type="string" indexed="true" stored="true" required="true" />
<field name="place" type="string" indexed="true" stored="true" required="true" />
<field name="sal" type="string" indexed="true" stored="true" required="true" />
<field name="name" type="string" indexed="true" stored="true" required="true"/>
Added the above lines to manage schema
Jar files added to lib folder of my core are
cassandra-driver-core-3.1.4.jar
cassandra-driver-extras-3.1.4.jar
cassandra-driver-mapping-3.1.4.jar
Now, when I run solr dih files, core does not give any requests as well it does not show any error messages. I'm throughly out of my mind.
Can we use the specified jar files to connect cassandra and solr? If so, where I'm wrong? Or else if we need to use the integrated one are we supposed to use only DSE search?
Thanks in advance.
how do i can search multiple index content in spring data solr showcase?
just now i only can search "name".
for example how do i can search "companyNo"?.
thanks in advance
sample xml of indexed in solr:
<?xml version="1.0" encoding="UTF-8"?>
<add>
<doc>
<field name="id">1051879H_15082014_00003457</field>
<field name="name">BEST MEGALINK SDN. BHD.</field>
<field name="entityName"></field>
<field name="companyNo">1051879-H</field>
<field name="noticeType">RMAT_N_C</field>
<field name="noticeDate">15/08/2014</field>
<field name="repNames"></field>
<field name="repNames"></field>
<field name="repNames"></field>
<field name="repICs"></field>
<field name="repICs"></field>
<field name="repICs"></field>
<field name="format">PDF</field>
<field name="folder">15082014</field>
<field name="pages">2</field>
</doc>
</add>
Other fields which need to be searched, needs to be added as part of schema.xml.
For example, the fields like the following needs to be added as part schema.xml:
<field name="entityName" type="text_string" indexed="true" stored="true"/>
<field name="companyNo" type="text_string" indexed="true" stored="true"/>
<field name="noticeType" type="text_string" indexed="true" stored="true"/>