How to give weight to the specific field? - java

I am using Apache Solr for indexing and searching. I have to give weight to the specific field so that If I make search then search has to perform on that field which is most weighted and then on others.
I am using SolrJ, Java, and GWT for development.

To boost at index time you need to supply a boost statement in your update doc.
<add overwrite="true">
<doc boost="2.0">
<field name="id">1234</field>
<field name="type">type1</type>
</doc>
<doc>
<field name="id">2345</field>
<field name="type" boost="0.5">type2</type>
</doc>
</add>
The above example demonstrates how to boost a complete document (elevation) as well as how to boost a specific field.
For more documentation look here and here

Using the dismax (or edismax) query handler, you can set the qf (Query Fields) parameter to assign boosts to different fields. It uses this format:
field1^boost_val field2^boost_val....etc.
There are other good parameters to help you control your result ranking as well.
http://wiki.apache.org/solr/ExtendedDisMax

Related

JPOS remove zero padding IFB_NUMERIC

the problem is in the fourth field (and maybe 11):
<field id="4" value="000000010000"/>
it should be:
<field id="4" value="10000"/>
I used IFB_NUMERIC isoFieldPackager for this field. Does correct isofieldpackager exist for my case? Or I need to some other decision...
thanks in advance!
jPOS doesn't perform content manipulation like unpadding. The packager just put what it reads and is the responsibility of the higher-level logic to make the unpadding.
You can use ISOUtil.zeroUnpad(m.getString(4)) method for that.

New Test Run using REST API - ALM 14

I am trying to update the test results using REST API for ALM Saas
http://targetserver:targetport/qcbin/rest/domains/ALMDomain/projects/ALMProject/runs - EndPoint
Below are the body(payload):
<Entity Type='run'>
<Fields>
<Field Name='name'><Value>testnamegoeshere</Value></Field>
<Field Name='test-instance'><Value>1</Value></Field>
<Field Name='cycle-id'><Value>cycleidgoeshere</Value></Field>
<Field Name='test-id'><Value>testidgoeshere</Value></Field>
<Field Name='subtype-id'><Value>hp.qc.run.MANUAL</Value></Field>
<Field Name='status'><Value>Failed</Value></Field>
<Field Name='owner'><Value>testownergoeshere</Value></Field>
</Fields>
</Entity>
Getting response is like this.
false
here is my question: I need to know if am passing correct parameter or not and please let me know, is API got changed or anything else??
URL you mentioned is for creating a new run. You have mentioned that you are going to update the test run. For that you need to append /{id} (id of run). Make sure you are making put call and not post for this operation.
Also probably you wont require to give cycle-id, test-id, test-instance details with update because those are now constants. If you are creating new run then it is mandatory.
Hope this helps you to solve.

How to index existing documents in java with Solr

I am trying to write an indexer for a search engine in Solr, using Java. I've been googling a lot. I found different approaches such as using a Core Container which adds the document and then the Solr server indexes all the data. another approach is to use Nutch, using Solr Indexer.
I am new with Solr and do not know which code to use. BTW, I need to have the stored indexed document. I do not know where Solr is saving the indexed documents.
BTW, would it be better to use Nutch?
I am so new with Solr, so any help would be appreciated.
You can use the Solr Data Import Handler.
Basically, in the core you create a data-config.xml with the datasource
<dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/dbname" user="db_username" password="db_password"/>
and then you define how should Solr map the database information into Solr indexes something like:
<document name="products">
<entity name="item" query="select * from item">
<field column="ID" name="id" />
</entity>
</document>
More reference here.
Also, if you need to use Java code, you can try with spring-data-solr.
Hope this helps!

Lucene/Solr - Indexing publications/texts

I want to be able to search publications with facets. These documents will be annotated so I will upload the annotation to the solr instance. The annotation will have fields which are the terms in the document. Here is an example:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<add>
<doc>
<field name="Title">High Glucose Increases the Expression of Inflammatory Cytokine Genes in
Macrophages Through H3K9 Methyltransferase Mechanism.</field>
<field name="Cytokine">INTERFERON </field>
<field name="Cytokine">CYTOKINE </field>
<field name="Cytokine">CYTOKINE</field>
<field name="Cytokine">MEC</field>
<field name="Cytokine">EPA</field>
<field name="Cytokine">DIA</field>
<field name="Cytokine">FIC</field>
<field name="Cytokine">CYTOKINES</field>
<field name="Cytokine">INTERLEUKIN-6 </field>
<field name="Cytokine">INTERLEUKIN</field>
<field name="Cytokine">IL-12P40</field>
<field name="Cytokine">IL-12</field>
<field name="Cytokine">IL-1</field>
<field name="Cytokine">P40</field>
<field name="Cytokine">MACROPHAGE INFLAMMATORY PROTEIN-1</field>
<field name="Cytokine">MACROPHAGE INFLAMMATORY PROTEIN</field>
</doc>
</add>
These terms are all from a Cytokine ontology.
I want be able to set the facet as Cytokine, then select the term and find all of the documents that contain the selected term.
Here is the catch:
I want to be able to store the location of said term found in the
document (it can show up in multiple locations. So I can highlight
later). All of these locations are stored in the annotation.
I want to be able to select one of the terms from the facet and also
bring up documents that contains that terms synonyms but not upload it as a term in the facet (or it being distinguished as a synonym some how (like subcategory)). e.g. automobile
and car
I want to be able to do a cross search e.g. find documents that
contain MEC and EPA.
I have a list of terms I do want to index and want to search the
documents by. These terms have synonyms which I have entered into the
synonyms.txt file.
Also When a term shows up multiple times in the document the annotation has multiple instances of this term with different locations, how should I handle this? Will solr automatically deal with duplication and not give me the documents twice?
One more thing: What about uploading the entire publication to solr, and indexing it on the predefined list of terms?
I understand that, you have synonyms and a search term should be verified directly and also with synonyms and return the results. Let me know if I got it.
If you have all the synonyms while indexing, then you can index them as multi valued field and search on that field.
Faceting is for searching, where the results are grouped.

JAXB multiple mappings for attribute

I'm just changing design errors made in the past, but want to keep backwards compatibility of my software. For this I would need some way to map two flavors of an xml file into one java bean. Can this be done using two JAXB annotations on one attribute/element? I understand the marshalling would be ambiguous, but the unmarshalling could work. Is there some nice way of doing this?
p.s.: I don't care about marshalling.
You can map twice:
the first time using annotations
the second time using XML resources.
Or just two XML mappings instead of annotations.
For XML resource mappings, there's a number of options:
Annox: http://confluence.highsource.org/display/ANX/JAXB+User+Guide (I wrote it so it comes first :))
EclipseLink Moxy: http://eclipse.org/eclipselink/moxy.php
JAXB Intoductions: http://community.jboss.org/wiki/JAXBIntroductions
With Annox you can easily map twice using XML mapping resources with different extensions like MyClass.ann1.xml or MyClass.ann2.xml. (It's MyClass.ann.xml per default, but the adjustment is trivial.)
Here's a sample of what mappings look like:
<class xmlns="http://annox.dev.java.net" xmlns:annox="http://annox.dev.java.net" xmlns:jaxb="http://annox.dev.java.net/javax.xml.bind.annotation">
<jaxb:XmlAccessorType value="FIELD"/>
<jaxb:XmlType name="" propOrder="productName quantity usPrice comment shipDate"/>
<field name="productName">
<jaxb:XmlElement required="true"/>
</field>
<field name="usPrice">
<jaxb:XmlElement name="USPrice" required="true"/>
</field>
<field name="shipDate">
<jaxb:XmlSchemaType name="date"/>
</field>
<field name="partNum">
<jaxb:XmlAttribute required="true"/>
</field>
</class>

Categories

Resources