Use Solr to index/search txt file content - apache

I'm making a study to compare different search platforms' performance over Twitter's tweets. For my purpose I have collected a set of tweets (around 50,000) and saved them in a single text (.txt) file in a format similar to the following:
Tweet ID User Tweet Content Tweet Time-stamp
The data would look like this:
31261817690923008 username1 tweet 1 content goes here 1482180069
31132193287839744 username2 tweet 2 content goes here 1274400000
Now, using Solr 6.3.0, is it possible to index each line of content separately? Instead, should I use XML or JSON? or do I have to store each line (tweet) in a different file?

You can use the CSV Update Handler, which will result in a single document for each row.
To adjust the parsing to the structure you've used, you can use separator (TAB? %09) to provide the separator used between fields / columns, encapsulator to set the value used to encapsulate a single field value (it doesn't seem you've used any) and fieldnames to provide a proper field name for each column, unless they're in the first row - in that case set header to true (and don't provide fieldnames).

Assuming two things:
#1 You do not want to do an awful lot of coding for the data entry.
#2 Your text file is TAB or comma separated.
If so, you can easily turn it into an XML that can be added via the Admin interface.
A few things to keep in mind:
Enclose your data in <add> ... </add> blocks of a reasonable size. Ideally not 50K. Experiment a little.
Enclose each entry - line in your case in <doc> ... <doc>
Each column needs to have its own field as in
<field name="id"> ... </field>
<field name="username"> ... </field>
...
All need unique IDs.
For practical purposes, if you can open the textfile in a spreadsheet, add the tag columns in between your data and then concatenate the lines, it is relatively easy even if a little labour intensive for 50K.
A doc set of two would look something like:
<add>
<doc>
<field name="id"> ... </field>
<field name="user"> ... </field>
<field name="content"> ... </field>
<field name="time_stamp"> ... </field>
</doc>
<doc>
<field name="id"> ... </field>
<field name="user"> ... </field>
<field name="content"> ... </field>
<field name="time_stamp"> ... </field>
</doc>
</add>

Related

How to reference a planning type in a plan

I have a custom odoo module, which extends some existing modules like hr. I want to create an onboarding plan with several predefined tasks in it.
This is my plan acitivity type xml which works at it should. If I update the applikation with this file, I get the desired tasks in the planning types overview.
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="hr_plan_activity_type_create_work_contract" model="hr.plan.activity.type">
<field name="activity_type_id" ref="mail.mail_activity_data_todo"/>
<field name="responsible">manager</field>
<field name="summary">Create work contract</field>
<field name="note">Create the work contract for the employee.</field>
</record>
<record id="hr_plan_activity_type_employee_model_in_erp" model="hr.plan.activity.type">
<field name="activity_type_id" ref="mail.mail_activity_data_todo"/>
<field name="responsible">manager</field>
<field name="summary">Employee model in ERP</field>
<field name="note">Complete the employee model in ERP (AHV, Banking, etc.)</field>
</record>
</odoo>
This is my plan.xml which should create a plan with the activity types. The creation of the plan works, but if I reference the activity types, I'll get an error message.
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Onboarding -->
<record id="hr_plan_onboarding" model="hr.plan">
<field name="name">Onboarding</field>
<field name="plan_activity_type_ids"
eval="[(6,0,[ref('mycompany.hr_plan_activity_type_employee_model_in_erp')])]"/>
<field name="plan_activity_type_ids"
eval="[(4,0,[ref('mycompany.hr_plan_activity_type_create_work_contract')])]"/>
</record>
</odoo>
In the manifest.py file I first load the plan.activity.type.xml and then the plan.xml so this shouldn't be a problem.
This is the error message I get when I try to upgrade my customized module mycompany:
File "C:\Program Files (x86)\Odoo 13.0e\server\odoo\addons\base\models\ir_model.py", line 1670, in xmlid_lookup
raise ValueError('External ID not found in the system: %s' % xmlid)
odoo.tools.convert.ParseError: "External ID not found in the system: hr.plan.activity.type.hr_plan_activity_type_create_work_contract" while parsing file:/c:/users/myuser/appdata/local/openerp%20s.a/odoo/addons/13.0/mycompany/data/hr/plan.xml:2, near
<odoo>
<!-- Onboarding -->
<record id="hr_plan_onboarding" model="hr.plan">
<field name="name">Onboarding</field>
<field name="plan_activity_type_ids" ref="hr.plan.activity.type.hr_plan_activity_type_create_work_contract"/>
</record>
Does anyone have any ideas?
String identifier stored in ir.model.data, can be used to refer to a record regardless of its database identifier during data imports or export/import roundtrips.
External identifiers are in the form module.id (e.g. account.invoice_graph). From within a module, the module. prefix can be left out.
Sometimes referred to as xml id or xml_id as XML-based Data Files make extensive use of them.
In your example you used model_name.id which probably does not exist in the database, to reference hr_plan_activity_type_create_work_contract record you just need to replace the model name with the module name.
I can see from the log message that the module name is mycompany, try to replace the model name with mycompany:
<record id="hr_plan_onboarding" model="hr.plan">
<field name="name">Onboarding</field>
<field name="plan_activity_type_ids" ref="mycompany.hr_plan_activity_type_create_work_contract"/>
</record>
Update:plan_activity_type_ids is an x2many field
Use the special commands format to set the x2many field values:
<record id="hr_plan_onboarding" model="hr.plan">
<field name="name">Onboarding</field>
<field name="plan_activity_type_ids" eval="[(6,0,[ref('mycompany.hr_plan_activity_type_create_work_contract')])]"/>
</record>
Edit: Only the first one shows up in the GUI
To replaces all existing records in the set by the ids list (using '(6, 0, ids)') you can provide a list of ids inside the triplet. You can find an example in res_partner_demo.xml inside the base module.
Example:
<field name="plan_activity_type_ids" eval="[(6,0,[ref('mycompany.hr_plan_activity_type_employee_model_in_erp'), ref('mycompany.hr_plan_activity_type_create_work_contract')])]"/>
To add an existing record of id id to the set (using (4, id)) you need to provide one id for each triplet. You can find an example in base_groups.xml inside the base module.
Example:
<field name="plan_activity_type_ids" eval="[(4,ref('mycompany.hr_plan_activity_type_employee_model_in_erp')), (4,ref('mycompany.hr_plan_activity_type_create_work_contract'))]"/>
Your ref ids are wrong. hr.plan.activity.type.hr_plan_activity_type_create_work_contract is wrong. You get only one . in a reference. its [<module_name>.]ext_id_of_object.
If you reference the object from the same module you don't have to use module name.part
If you can see the database tables. then things you are referencing are in table ir_model_data
So if the thing you are referencing is in your own model then you cant use just hr_plan_activity_type_create_work_contract as a reference or your_model_name.hr_plan_activity_type_create_work_contract

import user-defined Defaults Odoo

Today I tried to import some configuration from one data base of Odoo to another (User-defined Defaults) and everything looks ok, but the default values that i'm trying to insert to my new data base (for many2many fields) don't work. I believed it was by for the csv file and i try to add using xml record like this:
<record id="hr_test_record" model="ir.values">
<field name="value_unpickle">2</field>
<field name="name">struct_id</field>
<field name="model">hr.contract</field>
<field name="key">default</field>
<field name="value">I2 .</field>
</record>
but in the database space (for value) appears this way after install the module
value
S'2' +
p0 +
.
And has to look like this
value
I2 +
.
I know this but how can apply this?
I is for Integer
S is for string
V is for value
To store the value as integer, you must use XML notation to encode the \n character (result of pickle.dumps operation) and must not specify a value for the field "value_unpickle".
e.g.
<record id="hr_test_record" model="ir.values">
<field name="name">struct_id</field>
<field name="model">hr.contract</field>
<field name="key">default</field>
<field name="key2"/>
<field name="value">I2
.</field>
</record>
note that you also need to set key2 to empty string if you don't want any conditions/qualifiers for your default value.
(the above is tested in odoo 10)

set other account in accounting module

I am trying to set default account for some fields for that i write some code like
<!-- 1.Income account–311000 -->
<record forcecreate="True" id="property_account_income_product" model="ir.property">
<field name="name">property_account_income</field>
<field name="fields_id" search="[('model','=','product.template'),('name','=','property_account_income')]"/>
<field eval="'account.account,'+str(account_account_456)" name="value"/>
<field name="company_id" ref="base.main_company"/>
</record>
in account.account.template i write code like
<record model="account.account.template" id="account_account_456">
<field name="name">INCOME FROM SALES</field>
<field name="code">311000</field>
<field name="type">other</field>
<field name="user_type" ref="account.data_account_type_income"/>
<field name="reconcile" eval="False"/>
<field name="parent_id" ref="account_account_256"/>
</record>
but after update database it sets different account
i don't know why but correct account are not set
pleas help me
thanks...
Now i got exact Problem Firstly i put record in account.account.template this record is also automatically added into account.account and when i am trying to add record into ir.property search that Account into account.account.template take id and display record from account.account
so the problem is id mismatch in account.account and account.account.template
how to resolve this problem and sorry for English
This is because you must having multiple entries in model="ir.property" for field property_account_income_product for your company so when you try an see the values for the a/c you will find the first value get set on field as your record may be second in list, so it get not selected.

How to update a lookup field using a web service

I have a Nintex workflow and I am using a "Call Web Service" action to add a new list item in another site. I want to update a lookup field in the destination list from a lookup field in the source list. This is my CAML query
<UpdateListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listName>Kaizen Blast Objectives</listName>
<updates>
<Batch OnError="Continue" ListVersion="1" ViewName="">
<Method ID="1" Cmd="New">
<Field Name="ID">New</Field>
<Field Name="Title">{ItemProperty:Title}</Field>
<Field Name="Event_x0020_Driver">{ItemProperty:Event_x0020_Driver}</Field>
<Field Name="Problem_x0020_Statement">{ItemProperty:Problem_x0020_Statement}</Field>
<Field Name="Group1">{ItemProperty:Group}</Field>
</Method>
</Batch>
</updates>
</UpdateListItems>
"Group1" is a lookup field in the destination list and "Group" ({ItemProperty:Group}) is a lookup field in the source list.
A simple assignment like I have doesn't seem to work.
EDIT
The lookup field in the destination list is a site column.
Any ideas?
I figured it out. When updating a lookup field the format has to be id;#value. This is true even if the source and the destination fields are of the same data type.

Avoiding Boxing/Unboxing on unknown input

I am creating an application that parses an XML and retrieves some data. Each xml node specifies the data (const), a recordset's column-name to get the data from (var), a subset of possible data values depending on some condition (enum) and others. It may also specify, alongside the data, the format in which the data must be shown to the user.
The thing is that for each node type I need to process the values differently and perform some actinons so, for each node, I need to store the return value in a temp variable in order to later format it... I know I could format it right there and return it but that would mean to repeat myself and I hate doing so.
So, the question: How can I store the value to return, in a temp variable, while avoiding boxing/unboxing when the type is unknown and I can't use generics?
P.S.: I'm designing the parser, the XML Schema and the view that will fill the recordset so changes to all are plausible.
Update
I cannot post the code nor the XML values but this is the XML structure and actual tags.
<?xml version='1.0' encoding='utf-8'?>
<root>
<entity>
<header>
<field type="const">C1</field>
<field type="const">C2</field>
<field type="count" />
<field type="sum" precision="2">some_recordset_field</field>
<field type="const">C3</field>
<field type="const">C4</field>
<field type="const">C5</field>
</header>
<detail>
<field type="enum" fieldName="some_recordset_field">
<match value="0">M1</match>
<match value="1">M2</match>
</field>
<field type="const">C6</field>
<field type="const">C7</field>
<field type="const">C8</field>
<field type="var" format="0000000000">some_recordset_field</field>
<field type="var" format="MMddyyyy">some_recordset_field</field>
<field type="var" format="0000000000" precision="2">some_recordset_field</field>
<field type="var" format="0000000000">some_recordset_field</field>
<field type="enum" fieldName ="some_recordset_field">
<match value="0">M3</match>
<match value="1">M4</match>
</field>
<field type="const">C9</field>
</detail>
</entity>
</root>
Have you tried using the var type? That way you don't need to know the type of each node. Also, some small sample of your scenario would be useful.