I've been trying to configure Solr to work with my Oracle 11.2 database as a datasource but nothing works. I have thoroughly explored the documentations and it seems to lack a good and working guide.
For a simple scenario, I want to index my single table [topic]
The structure of my table topic is shown below:
ID (autonumber)
Topic (varchar 50) I want to index this
Info (varchar 255) I want to index this
My solr configurations (so far)
I have added a new collection for this Oracle, name it "oracle_test". So I configure the folder structure as guided by the official documentation for this collection as follows:
~/solr/server/solr/
oracle_test
conf
data-config.xml
elevate.xml
schema.xml
solrconfig.xml
data-config.xml
I have configured a working datasource connection string to my Oracle, specified the query to my topic table, also the fields I want Solr to look up.
<dataConfig>
<dataSource name="jdbc" driver="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:system#//127.0.0.1:1521/orcl/" user="system" password="*****"/>
<document>
<entity name="help" query="select \"topic\",\"info\" from \"topic\"" dataSource="jdbc">
<field column="topic" name="topic"/>
<field column="info" name="info"/>
</entity>
</document>
</dataConfig>
schema.xml
I put the definitions of fields here.
<schema name="oracle_help" version="1.1">
<fieldType name="string" class="solr.StrField"/>
<field name="topic" type="string" indexed="true" stored="true" multiValued="false"/>
<defaultSearchField>info</defaultSearchField>
<field name="topic" type="string" indexed="true" stored="true"/>
<field name="info" type="string" indexed="true" stored="true"/>
</schema>
solrconfig.xml
Since the configuration file is big and it includes everything. I will take only some excerpts from this configuration file which is related to the Oracle configuration as follows:
I specify which field (topic) I want it to index:
<initParams path="/update/**,/query,/select,/tvrh,/elevate,/spell,/browse">
<lst name="defaults">
<str name="df">topic</str>
</lst>
</initParams>
Under processor section, I have only one default field type defined as string:
<processor class="solr.AddSchemaFieldsUpdateProcessorFactory">
<str name="defaultFieldType">strings</str>
...
</processor>
Then I tried importing the datasource via Solr Admin
Using "DataImport" on Solr Admin dashboard, once execute the command, I got this response back which I'm not sure whether it correctly indexed my Oracle table:
{
"responseHeader": {
"status": 0,
"QTime": 1
},
"initArgs": [
"defaults",
[
"config",
"data-config.xml"
]
],
"command": "status",
"status": "idle",
"importResponse": "",
"statusMessages": {}
}
Weird thing is, the status is indicated as "idle".
I tried to execute search query, but it returns error
Use the search query "test" as follows:
$> curl http://localhost:8983/solr/oracle_test/select?q=test&wt=json&indent=true
Solr returns me "undefined field topic".
{
"responseHeader": {
"status": 400,
"QTime": 1,
"params": {
"q": "called",
"indent": "true",
"wt": "json",
"_": "1434341618019"
}
},
"error": {
"msg": "undefined field topic",
"code": 400
}
}
But, as shown at the earlier part, obviously I have already defined the field "topic" in my schema.xml. It seems lack of documentation or guide on Solr official sites and I tried doing some research on Internet, but I've got nothing at all.
Can anybody who might be familiar with Solr - Oracle integration please help me figure this out? Any suggestion?
I think your Solr server should generate an error upon start-up or when you are trying to access the index that uses the schema.xml you have defined. Please have a look into the logs of your solr server.
It has formal errors, these prevent the index from starting and in turn the DIH you have defined from running
<types /> is missing around your field types
<fields /> is missing around your fields
<defaultSearchField /> is missplaced inside your fields
you have defined the field named topic twice
The structure of a schema.xml is documented in Solr's Wiki. A valid version of your schema.xml would look like the sample below.
<schema name="oracle_help" version="1.1">
<types>
<fieldType name="string" class="solr.StrField"/>
</types>
<defaultSearchField>info</defaultSearchField>
<fields>
<field name="topic" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="info" type="string" indexed="true" stored="true"/>
</fields>
</schema>
The approach which you are using seems to be fine. In solrConfig.xml try using below line
<str name="config">/path/to/my/DIHconfigfile.xml</str>
instead of <str name="df">topic</str>
Related
I have a FetchXML Query that returns the correct entities for my portal.
How do I get the translated values stored in my CRM
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
<entity name="testentity">
<attribute name="xyz_testclassification" />
<attribute name="xyz_schemaname" />
</entity>
</fetch>
Working with XML and assuming attribute "xyz_testclassification" is an option set type your FetchXML query could return a resultset like this:
<resultset morerecords="0">
<result>
<xyz_testclassification name="Option One" formattedvalue="10003">10003</xyz_testclassification><xyz_schemaname>One</xyz_schemaname>
</result>
<result />
<result>
<xyz_testclassification name="Option Two" formattedvalue="10004">10004</xyz_testclassification><xyz_schemaname>Two</xyz_schemaname>
</result>
<result>
<xyz_testclassification name="Option Three" formattedvalue="10001">10001</xyz_testclassification><xyz_schemaname>Three</xyz_schemaname>
</result>
</resultset>
Here XML attribute "name" contains the display name of the option value. Attribute "formattedvalue" is only useful for numeric attributes (int, decimal, double, money).
When you are using FetchXML in C#, method IOrganizationService.RetrieveMultiple will return Entity objects. The Entity class has a FormattedValues collection containing the display values.
All values are returned according to the language and formatting settings of the user on behalf of whom the system is queried.
I agree with Henk van Boeijen. I'd like to add that if you using the Web Api endpoint it is also possible by adding "Prefer: odata.include-annotations="OData.Community.Display.V1.FormattedValue" in the header of the request.
HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0
Preference-Applied: odata.include-annotations="OData.Community.Display.V1.FormattedValue"
{
"#odata.context": "[Organization URI]/api/data/v8.2/$metadata#accounts(name,donotpostalmail,accountratingcode,numberofemployees,revenue)",
"value": [
{
"#odata.etag": "W/"502170"",
"name": "Fourth Coffee (sample)",
"donotpostalmail#OData.Community.Display.V1.FormattedValue": "Allow",
"donotpostalmail": false,
"accountratingcode#OData.Community.Display.V1.FormattedValue": "Default Value",
"accountratingcode": 1,
"numberofemployees#OData.Community.Display.V1.FormattedValue": "9,500",
"numberofemployees": 9500,
"revenue#OData.Community.Display.V1.FormattedValue": "$100,000.00",
"revenue": 100000,
"accountid": "89390c24-9c72-e511-80d4-00155d2a68d1",
"transactioncurrencyid_value": "50b6dd7b-f16d-e511-80d0-00155db07cb1" } ]
}
For more details: https://msdn.microsoft.com/en-us/library/gg334767.aspx
I'm working on Employee Directory module in odoo11 and I want to set a notebook page invisible to the current user (Logged user) if he is different to the related user.
I tried to use user.id in XML but it does not work.
Here is my code :
<page name="hr_settings" string="HR Settings" attrs="{'invisible':[('user_id', '!=', user.id)]}">
<group>
<group string='Status' name="active_group">
<field name="company_id"/>
<field name="user_id" string="Related User"/>
</group>
</group>
</page>
The error message :
<class 'NameError'>: "name 'user' is not defined" while evaluating
"{'invisible': [('user_id', '!=', user.id)]}"
None" while parsing /opt/odoo/odoo/my_addons/hr_dz/views/employee_views.xml:5, near
<record id="view_employee_form" model="ir.ui.view">
<field name="name">hr.employee.form</field>
Any idea about that, please ?
One of the thing i know to use a field in attrs the field must be Mentionsed in the form. i don't know how to get the value of the user id in the form. but if there is not a short way like uid or user you can work arround this, just create a m2o field to res.users make this field compute field with store = False.
Please try this it useful to you.:
# by default store = False this means the value of this field
# is always computed.
current_user = fields.Many2one('res.users', compute='_get_current_user')
#api.depends()
def _get_current_user(self):
for rec in self:
rec.current_user = self.env.user
# i think this work too so you don't have to loop
self.update({'current_user' : self.env.user.id})
and you can use this field in your form.
<page name="hr_settings" string="HR Settings" attrs="{'invisible':[('user_id', '=', current_user)]}">
<group>
<group string='Status' name="active_group">
<field name="company_id"/>
<field name="user_id" string="Related User"/>
</group>
</group>
</page>
In your case basically, we can achieve directly with uid global expression variable on view level.
uid is also used into the expression evaluation in odoo xml view file
<page name="hr_settings" string="HR Settings" attrs="{'invisible':[('user_id', '!=', uid)]}">
<group>
<group string='Status' name="active_group">
<field name="company_id"/>
<field name="user_id" string="Related User"/>
</group>
</group>
</page>
No need to add and create any compute field for the code.
Please see the following view under the addons of Odoo V11
addons/project/project_view.xml.
view.xml
<field name="planning_id"/>
<field name="employee"/>
<field name="job_position" />
I want to display the job_position which is matched with the similar companies of planning_id(job_position.company_id=planning_id.company).
I tried with domain but its not working.
<field name="job_position" domain="'company_id'=planning_id.company_id"/>
First of all you need to create a related field to have the company in the same model, so, in the .py of your model:
company_id = fields.Many2one(related='planning_id.company_id')
Then, in the view:
<field name="job_position" domain="[('company_id', '=', company_id)]"/>
I need to create a popup treeview like the one in picture below, and then can select as many items as I need to be inserted to the original tree-view
If you want it to give you a popup containing a tree view where you can choose from the list. You need to have a many2many relation between the 2 modules, it seems like you have one2many relation.
if your field is a one2many field from what i understand your field must be a one2many field because in one2many field when you click on add item it send you direclty to a create popup in order to change this behavor you need to change the widget of this field like this :
<field name="you_o2m_field_name" widget="many2many" >
<tree>
<field name="field_name1"/>
<field name="field_name1"/>
<field name="field_name1"/>
</tree>
<form>
<!-- you can put a costum form view also here -->
</form>
</field>
but you i think you need to give it an option not_delete like this
<field name="you_o2m_field_name" widget="many2many" options="{'not_delete':True}"/>
because when you remove the record from the tree one2many delete it from the table if you want to keep it then use no_delete option
define a search view for the model exam
<record id="id_for_this_view_here" model="ir.ui.view">
<field name="model">model.name</field>
<field name="arch" type="xml">
<search string="recherche" >
<field name="field_name" />
<field name="field_name"/>
</search>
</field>
</record>
the frame work will create a search view for you if you don't specify one for your model this why the search have only create by ok so whenever you have a search view with create by you need to define a _rec_name for your model or create a search view
<record model="ir.actions.act_window" id="open_gtd_all_tasks_pci">
<field name="name">Tasks (GTD)</field>
<field name="res_model">project.task</field>
<field name="search_view_id" ref="project_gtd.view_task_gtd_search"/>
<field name="context">{'set_visible': True, 'gtd': True, 'search_default_timebox_id': 1, 'search_default_open': 1, 'search_default_open_project': 1, 'hide_stage': 0}</field>
<field name="view_type">form</field>
<field name="view_mode">kanban,tree,form,calendar,gantt,graph</field>
</record>
<record id="planningtask_calendar_view_inherit" model="ir.ui.view">
<field name="name">ic.team.planning.task.calendar.inherit</field>
<field name="model">ic.team.planning.task</field>
<field name="inherit_id" ref="ic_project_issue.ic_team_planning_task_calendar_view"/>
<field name="arch" type="xml">
<xpath expr="//calendar[#string='Team Planning']" position="attributes">
<attribute name="mode">week</attribute>
</xpath>
</field>
</record>
what different res_model with model,what the effect , when use model or res_model? i need explained :-)
Here we have major different between res_model and model,
For Odoo Action of View:
model :
In model action is important for base record for the database table hear which is used to store the particular action of that record id.
In your example :
model="ir.actions.act_window" As a ir_actions_act_window database table
id="open_gtd_all_tasks_pci" As a unique id for that action table record
which is used to create a new record with the id,res_model,search_view_id,context,view_type,view_mode with ir_actions_act_window database table
res_model :
Action of the particular model
For Odoo Design of View:
for model="ir.ui.view" for the record as ir_ui_view database table to store a new record as planningtask_calendar_view_inherit unique id
and same as for name,model,inherit_id fields for storing the record.
hear model field is for desgin the view for that particular model (database table).
In generally Odoo(OpenERP) understand . (dot) with particular model name and make it as _(underscore) and store that record it as the database table.
like res.partner module Odoo (formally OpenERP) treat as res_partner database table.