Ya, structured data gets a little funny.
For starters, the order of multi-valued fields should be maintained,
so if you have:
<doc>
<field name="url">http://aaa</field>
<field name="url_rank">5</field>
<field name="url">http://bbb</field>
<field name="url_rank">4</field>
</doc>
the response will return result in order, so you can map them with
array indicies.
I have played some tricks with a JSON field analyzer that give you
some more control.
For example, if you index:
<doc>
<field name="url">{ url:"http://host/", rank:5 }</field>
</doc>
Then I use an analyzer that indexes the terms:
url:http://host/
rank:5
I just posted SOLR-1690, if you want to take a look at that approach
ryan
On Dec 30, 2009, at 4:25 AM, magui wrote:
Thanks Sascha for your post, but i find it interresting, but in my
case i
don't want to use an additionnal field, i want to be able with the
same
schema to do a simple query like : "q=res_url:some url", and a query
like
the other one;
in other word; is there any solution to make two or more multivalued
fields
in the same document linked with each other, e.g:
in this result:
- <result name="response" numFound="1" start="0">
- <doc>
<str name="id">1</str>
<str name="keyword">Key1</str>
- <arr name="res_url">
<str>url1</str>
<str>url2</str>
<str>url3</str>
<str>url4</str>
</arr>
- <arr name="res_rank">
<str>1</str>
<str>2</str>
<str>3</str>
<str>4</str>
</arr>
</doc>
</result>
i would like to make solr understand that for this document,
value:url1 of
"res_url" field is linked to value:1 of "res_rank" field, and all of
them
are linked to the commen field "keyword".
I think that i should use a custom field analyser or some thing like
that;
but i don't know what to do.
but thanks for all; and any supplied help will be lovable.
Sascha Szott wrote:
Hi,
you could create an additional index field res_ranked_url that
contains
the concatenated value of an url and its corresponding rank, e.g.,
res_rank + " " + res_url
Then, q=res_ranked_url:"1 url1" retrieves all documents with url1
as the
first url.
A drawback of this workaround is that you have to use a phrase query
thus preventing wildcard searches for urls.
-Sascha
Hello everybody, i would like to know how to create index
supporting a
parent/child mapping and then querying the child to get the results.
in other words; imagine that we have a database containing 2
tables:Keyword[id(int), value(string)] and Result[id(int),
res_url(text),
res_text(tex), res_date(date), res_rank(int)]
For indexing, i used the DataImportHandler to import data and it
works
well,
and my query response seems good:(q=*:*) (imagine that we have
only this
to
keywords and their results)
<?xml version="1.0" encoding="UTF-8" ?>
-<response>
-<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">0</int>
-<lst name="params">
<str name="q">*:*</str>
</lst>
</lst>
-<result name="response" numFound="2" start="0">
-<doc>
<str name="id">1</str>
<str name="keyword">Key1</str>
-<arr name="res_url">
<str>url1</str>
<str>url2</str>
<str>url3</str>
<str>url4</str>
</arr>
-<arr name="res_rank">
<str>1</str>
<str>2</str>
<str>3</str>
<str>4</str>
</arr>
</doc>
-<doc>
<str name="id">2</str>
<str name="keyword">Key2</str>
-<arr name="res_url">
<str>url1</str>
<str>url5</str>
<str>url8</str>
<str>url7</str>
</arr>
-<arr name="res_rank">
<str>1</str>
<str>2</str>
<str>3</str>
<str>4</str>
</arr>
</doc>
</result>
</response>
but the problem is when i tape a query kind of
this:"q=res_url:url2 AND
res_rank:1" and this to say that i want to search for the keywords
in
which
the url (url2) is ranked at the first position, i have a result like
this:
<?xml version="1.0" encoding="UTF-8" ?>
-<response>
-<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">0</int>
-<lst name="params">
<str name="q">res_url:url2 AND res_rank:1</str>
</lst>
</lst>
-<result name="response" numFound="1" start="0">
-<doc>
<str name="id">1</str>
<str name="keyword">Key1</str>
-<arr name="res_url">
<str>url1</str>
<str>url2</str>
<str>url3</str>
<str>url4</str>
</arr>
-<arr name="res_rank">
<str>1</str>
<str>2</str>
<str>3</str>
<str>4</str>
</arr>
</doc>
</result>
</response>
But this is not true; because the url present in the 1st position
in the
results of the keyword "key1" is url1 and not url2.
So what i want to say is : is there any solution to make the
values of
the
"multivalued" fields linked;
so in our case we can see that the previous result say that:
- url1 is present in 1st position of "key1" results
- url2 is present in 2nd position of "key1" results
- url3 is present in 3rd position of "key1" results
- url4 is present in 4th position of "key1" results
and i would like that solr consider this when executing queries.
Any helps please; and thanks for all :)
--
View this message in context:
http://old.nabble.com/how-to-do-a-Parent-Child-Mapping-using-entities-tp26956426p26965478.html
Sent from the Solr - User mailing list archive at Nabble.com.