Solr field depth - solr

How would one set up Solr such that we have "child" node fields?
For example, for this doc, there exists 2 cars, but each car has a subset of colors.
For example:
<doc>
<field name = "make"> Toyota </field>
<field name = "car"> Camri </field>
<field name = "color"> Silver </field>
<field name = "color"> Red </field>
<field name = "car"> Corolla </field>
<field name = "color"> Blue </field>
<field name = "color"> Red </field>
<doc>
How would one go about getting these relationships indexed?

The general practice is to denormalize the database as Solr works with a plain schema. For example, you can make a multi-valued field and put these values into it:
Camri/Silver
Camri/Red
Corolla/Blue
Corolla/Red

Related

How to separate the values of a multivalued field into dynamic fields

I have 1 multivalued date type field, its definition in the schema.xml is shown below:
<field name="fecha_referencia" type="pdates" uninvertible="true" indexed="true" stored="true"/>
The total of values it can take are three, here is an example where it is already indexed:
fecha_referencia:["2015-12-04T00:00:00Z",
"2014-12-15T00:00:00Z",
"2014-02-03T00:00:00Z"]
I want to know is if you can divide the values at the time of indexing (I am indexing via DIH) into other dynamic fields or separate fields.
Example of what you are looking for:
fecha_referencia:["2015-12-04T00:00:00Z",
"2014-12-15T00:00:00Z",
"2014-02-03T00:00:00Z"],
fecha1:2015-12-04T00:00:00Z,
fecha2:2014-12-15T00:00:00Z,
fecha3:2014-02-03T00:00:00Z
Note: I have tried to test regex but have had no luck.
Any contribution would be of great help and well received by your server...
This is my data.config.xml structure:
<dataConfig>
<dataSource type="JdbcDataSource" driver="org.postgresql.Driver" url="jdbc:postgresql://10.152.11.47:5433/meta" user="us" password="ntm" URIEncoding="UTF-8" />
<document >
<entity name="tr_ident" query="SELECT id_ident, titulo,proposito,descripcion,palabra_cve
FROM ntm_p.tr_ident">
<field column="id_ident" name="id_ident" />
<field column="titulo" name="titulo" />
<field column="proposito" name="proposito" />
<field column="descripcion" name="descripcion" />
<field column="palabra_cve" name="palabra_cve" />
<entity name="tr_fecha_insumo" query="select fecha_creacion,fech_ini_verif,
fech_fin_verif from ntm_p.tr_fecha_insumo where id_fecha_insumo='${tr_ident.id_ident}'">
<field name="fecha_creacion" column="fecha_creacion" />
<field name="fech_ini_verif" column="fech_ini_verif" />
<field name="fech_fin_verif" column="fech_fin_verif" />
</entity>
<entity name="ti_fecha_evento"
query="select tipo_fecha,fecha_referencia from ntm_p.ti_fecha_evento where id_fecha_evento='${tr_ident.id_ident}'">
<field column="fecha_referencia" name="fecha_referencia" />
<entity name="tc_tipo_fecha" query="select des_tipo_fecha,id_tipo_fecha from ntm_p.tc_tipo_fecha where id_tipo_fecha='${ti_fecha_evento.tipo_fecha}'">
<field column="des_tipo_fecha" name="des_tipo_fecha" />
<field column="id_tipo_fecha" name="id_tipo_fecha" />
</entity>
</entity>
</entity>
</document>
</dataConfig>

How can i show checkbox in Odoo 12?

I want to show checkbox in Odoo 12. I try with my code but it's not working Please help me.
Here is my code of module.
class ProductTemplate(models.Model):
_inherit = 'product.template'
field_name1 = fields.Boolean(string="Product Barcode Generator")
Here is view Code:
<record id="product_template_form_parent_inherit" model="ir.ui.view">
<field name="name">product.template.form.parent.inherit</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<xpath expr="//notebook" position="inside">
<page string="Product Barcode Generator">
<label for="field_name1"/>
<field name="field_name1" />
</page>
</xpath>
</field>
</record>
Let me try:
Your External Id should be:
<field name="inherit_id" ref="product.product_template_only_form_view"/>

handling null value in nested entity of solr data importer

I'm using the Solr Data Importer to import some category data. I didn't want to use a left join in the parent query because it's too complicated, I preferred to use nested object queries in the configuration to keep it simple.
I've got 3 one to one relationships for feature images of a category. My question is though, how can I handle it when the value in mediaItemX_id field is null? I've tried the nested configuration below, but when the value is null it's reporting invalid sql because the nested query doesn't print null - it prints blank....
<entity name="category" query="SELECT concat('CATEGORY_', c.id) as docId, c.id, externalIdentifier, name, description, shortDescription, mediaItem1_id, mediaItem2_id, mediaItem3_id, created, lastUpdated, keywords, 'CATEGORY' as docType,
name as autoSuggestField
FROM categories c inner join base_content bc where c.id = bc.id">
<field column="id" name="categoryId" />
<field column="externalIdentifier" name="externalIdentifier" />
<field column="docType" name="docType" />
<field column="name" name="name" />
<field column="description" name="description" />
<field column="shortDescription" name="shortDescription" />
<field column="created" name="created" dateTimeFormat="yyyy-MM-dd'T'HH:mm:ss" />
<field column="lastUpdated" name="lastUpdated" dateTimeFormat="yyyy-MM-dd'T'HH:mm:ss" />
<field column="publishDate" name="publishDate" dateTimeFormat="yyyy-MM-dd'T'HH:mm:ss" />
<field column="archiveDate" name="archiveDate" dateTimeFormat="yyyy-MM-dd'T'HH:mm:ss" />
<field column="autoSuggestField" name="suburbSuggest" />
<field column="keywords" name="keywords" />
<entity name="mediaItem1" query="SELECT uri, title, altText from media where ${category.mediaItem1_id} is not null and id = ${category.mediaItem1_id}">
<field column="uri" name="featureImage1Url" />
<field column="title" name="featureImage1Title" />
<field column="altText" name="featureImage1AltText" />
</entity>
<entity name="mediaItem2" query="SELECT uri, title, altText from media where ${category.mediaItem2_id} is not null and id = ${category.mediaItem2_id}">
<field column="uri" name="featureImage2Url" />
<field column="title" name="featureImage2Title" />
<field column="altText" name="featureImage2AltText" />
</entity>
<entity name="mediaItem1" query="SELECT uri, title, altText from media where ${category.mediaItem3_id} is not null and id = ${category.mediaItem3_id}">
<field column="uri" name="featureImage3Url" />
<field column="title" name="featureImage3Title" />
<field column="altText" name="featureImage3AltText" />
</entity>
</entity>
Solr supports the notion ${value:default} as replacements in other locations, so I'd try that at least:
${category.mediaItem1_id} IS NOT NULL AND id = ${category.mediaItem1_id:0}
I were unable to find a decent way to skip the entities whole if the current value is false.

Solr fle layout with dynamic fields

Im a newbie to SOLR and trying to understand dynamic fields,
Assume I have the following schema,
If document-1, contains
id = 1, author = "Tom" , title = "Python", text = "Book", first_name_string = "Tom"and last_name_string = "Dan"
and If document-2, contains
id = 2, author = "Brain" , title = "Java" , text = "Java"
How would the values be stored?
Is it my first document-1 and document-2 will be stored as seen above..What will be the values first_name_string and last_name_string for my document-2?
If I do a query on both the documents, how will the SOLR results look..
<?xml verson='1.0' ?>
<schema name='simple' version='1.1'>
<types>
<fieldtype name='string' class='solr.StrField' />
<fieldType name='long' class='solr.TrieLongField' />
</types>
<fields>
<field name='id' type='long' required='true' />
<field name='author' type='string' multiValued='true' />
<field name='title' type='string' />
<field name='text' type='string' />
<dynamicField name='*_string' type='string'
multiValued='true' indexed='true' stored='true' />
<copyField source='*' dest='fullText' />
<field name='fullText' type='string'multiValued='true' indexed='true' />
</fields>
<uniqueKey>id</uniqueKey>
<defaultSearchField>fullText</defaultSearchField>
<solrQueryParser defaultOperator='OR' />
</schema>
If you dont provide data for any fields .solr will skip those fields for that doc.if you want to have all the fields in all the docs.please specify default for fields in your schema.

Why does the Solr Data Import Handler hashes the uniqueKey?

I have a very strange problem with Solr 4.6.0.
The uniqueKey field "id" contains a hash for every document instead of my string value. If add just one custom document with the update request handler in the Solr admin I get for example the ID value "book_45" that I specified, so that is correct.
But when I do a full import with the DIH (data import handler) then the id field contains a hash for every document like "[B#53bd370f" instead of my custom value. So the problem must be in the DIH.
My import script:
<dataConfig>
<dataSource
type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://host/database"
user="user"
password="password" />
<document name="project">
<entity name="document" transformer="RegexTransformer"
query="SELECT CONCAT('book_', b.id) AS book_id, b.slug, b.title, b.isbn,
b.publisher, b.releaseYear AS release_year, b.language, b.pageCount AS page_count, b.description,
b.print, b.addedBy_id AS added_by_id, b.dt AS created,
GROUP_CONCAT(a.name SEPARATOR ';') AS authors
FROM Book b
LEFT JOIN author_book ab ON ab.book_id = b.id
LEFT JOIN Author a ON a.id = ab.author_id
GROUP BY b.id
">
<field column="book_id" name="id" />
<field column="slug" name="book_slug" />
<field column="title" name="book_title" />
<field column="isbn" name="book_isbn" />
<field column="publisher" name="book_publisher" />
<field column="release_year" name="book_release_year" />
<field column="language" name="book_language" />
<field column="page_count" name="book_page_count" />
<field column="description" name="book_description" />
<field column="print" name="book_print" />
<field column="added_by_id" name="book_added_by_id" />
<field column="created" name="book_created" />
<field column="authors" splitBy=";" name="authors" />
</entity>
</document>
The id field in my schema.xml (which is the same as in the default shipped core collection1):
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<uniqueKey>id</uniqueKey>
Does anyone know what I am missing?
the [B#53bd370f is not a hash, but the result of a byte[].toString(). Whatever Mysql is returning is being treated as a byte[] instead of a String.
Try casting the id to varchar or char like this:
SELECT cast(CONCAT('book_', b.id) as CHAR) AS book_id...

Resources