Re: Sorting documents by child documents

2015-07-14 Thread DorZion
I can sort the parent documents with the ScoreMode function, you can take a
look here: 

http://lucene.472066.n3.nabble.com/Sorting-documents-by-nested-child-docs-with-FunctionQueries-tp4209940.html
<http://lucene.472066.n3.nabble.com/Sorting-documents-by-nested-child-docs-with-FunctionQueries-tp4209940.html>
  

I just want to sort the documents with the field, instead of FunctionQuery.
The sort mode takes the best score of the children and the parents are
sorted by that score. 

Here is what will happen if I use the sort I want:

*Original Query:*
Document 1
 Id: 5
 Children 1
 Id:51
 Title : "B"
 Children 2
 Id:52
 Title : "M"

Document 2
 Id: 6
 Children 1
 Id:61
 Title : "Y"
 Children 2
 Id:62
 Title : "Z"

Document 3
 Id: 6
 Children 1
 Id:61
 Title : "C"
 Children 2
 Id:62
 Title : "A"

*Sorted Query (By title field):*
Document 3
 Id: 6
 Children 1
 Id:61
 Title : "C"
 Children 2
 Id:62
 Title : "A"

Document 1
 Id: 5
 Children 1
 Id:51
 Title : "B"
 Children 2
 Id:52
 Title : "M"


Document 2
 Id: 6
 Children 1
 Id:61
 Title : "Y"
 Children 2
 Id:62
 Title : "Z"


As you can see, the documents are sorted by "title". The document with the
child that have the lowest "value" of the title field, will be the first in
the result. 

Thanks,

Dor



Alessandro Benedetti wrote
> I would like to get a deep understanding of your problem…
> How do you want to sort a parent document by a normal field of children ??
> 
> Example:
> 
> Document 1
>  Id: 5
>  Children 1
>  Id:51
>  Title : "A"
>  Children 2
>  Id:52
>  Title : "Z"
> 
> Document 2
>  Id: 6
>  Children 1
>  Id:61
>  Title : "C"
>  Children 2
>  Id:62
>  Title : "B"
> 
> How can you sort the parent based on children fields ?
> You can sort a parent based on a value calculated out of children fields (
> after you calculate an unique value out of them Max ? Sum ? Concat ? ext
> ext).
> 
> Can you explain better your problem ?
> 
> Cheers
> 
> 
> 2015-07-08 7:17 GMT+01:00 DorZion <

> Dorzion@

> >:
> 
>> Hey,
>>
>> I'm using Solr 4.10.2 and I have child documents in every parent
>> document.
>>
>> Previously, I used FunctionQuery to sort the documents:
>>
>>
>> http://lucene.472066.n3.nabble.com/Sorting-documents-by-nested-child-docs-with-FunctionQueries-tp4209940.html
>> <
>> http://lucene.472066.n3.nabble.com/Sorting-documents-by-nested-child-docs-with-FunctionQueries-tp4209940.html
>> >
>>
>> Now, I want to sort the documents by their child documents with normal
>> fields.
>>
>> It doesn't work when I use the "sort" parameter.
>>
>> Thanks in advance,
>>
>> Dor
>>
>>
>>
>> --
>> View this message in context:
>> http://lucene.472066.n3.nabble.com/Sorting-documents-by-child-documents-tp4216263.html
>> Sent from the Solr - User mailing list archive at Nabble.com.
>>
> 
> 
> 
> -- 
> --
> 
> Benedetti Alessandro
> Visiting card : http://about.me/alessandro_benedetti
> 
> "Tyger, tyger burning bright
> In the forests of the night,
> What immortal hand or eye
> Could frame thy fearful symmetry?"
> 
> William Blake - Songs of Experience -1794 England





--
View this message in context: 
http://lucene.472066.n3.nabble.com/Sorting-documents-by-child-documents-tp4216263p4217400.html
Sent from the Solr - User mailing list archive at Nabble.com.


Sorting documents by child documents

2015-07-07 Thread DorZion
Hey,

I'm using Solr 4.10.2 and I have child documents in every parent document.

Previously, I used FunctionQuery to sort the documents:

http://lucene.472066.n3.nabble.com/Sorting-documents-by-nested-child-docs-with-FunctionQueries-tp4209940.html

  

Now, I want to sort the documents by their child documents with normal
fields.

It doesn't work when I use the "sort" parameter. 

Thanks in advance,

Dor



--
View this message in context: 
http://lucene.472066.n3.nabble.com/Sorting-documents-by-child-documents-tp4216263.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Sorting documents by nested / child docs with FunctionQueries

2015-07-07 Thread DorZion
Now I'm trying to sort the children by normal field and not by function
values.

Is there any way to do so? 

Thanks,

Dor



--
View this message in context: 
http://lucene.472066.n3.nabble.com/Sorting-documents-by-nested-child-docs-with-FunctionQueries-tp4209940p4216169.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Sorting documents by nested / child docs with FunctionQueries

2015-06-09 Thread DorZion
Thanks for your reply.

I couldn't make it work. Everything went fine when I applied the patch and
compiled Solr, but I couldn't use the FunctionQuery with it.

My FunctionQuery accesses the field "text" in the document, however the
parent doesn't have that field, so the plugin raises an exception. When I
suppress the exception and return the minimum value instead, nothing
happens.

*Example of my query:*
"q": "*:*",
"parent_filter": "content_type:parent"
"child_filter": "content_type:child"
"indent": "true"
"fl": "*,[child parentFilter=$parent_filter childFilter=$child_filter]"
"fq": "{!parent which=$parent_filter v=$child_filter scoreMode=Max}"
"sort": "analyzeText(text) desc"

*Another example for what I'm doing in the FunctionQuery plugin (This isn't
the original code):*
 public FunctionValues getValues(Map map, AtomicReaderContext
atomicReaderContext) throws IOException {

final FunctionValues values =
mValueSource.getValues(map,atomicReaderContext);

return new FunctionValues() {
@Override
public float floatVal(int i) {
String value = values.strVal(i);

if(value == null || value.isEmpty()) {
return Float.NaN;
}

return value.length();
...
...
...
Other functions that use the and returns the floatVal value


Very grateful for your help,

Dor
 


Mikhail Khludnev wrote
> pickup the patch https://issues.apache.org/jira/browse/SOLR-5882 and/or
> chase committers.
> 
> On Fri, Jun 5, 2015 at 10:35 AM, DorZion <

> Dorzion@

> > wrote:
> 
>> Hey,
>>
>> I'm using Solr 5.0.0 and I'm trying to sort documents with
>> FunctionQueries.
>> The problem is that I'm trying to sort those documents with their child
>> documents elements.
>>
>> Here is an example:
>> I have three documents, one is parent, the others are child documents
>> (_childDocuments_).
>>
>> {
>> "id": "ArticleGuid",
>> "title" : "Sorting Child Documents",
>> "content_type": "article",
>> "_childDocuments_": [
>>   {
>> "id": "CommentGuid",
>> "content_type": "comment",
>> "text": "CommentText"
>>   },
>>   {
>> "id": "CommentGuid2",
>> "content_type": "comment",
>> "text": "CommentText"
>>   }
>> ]
>> }
>> *
>> * This is just an example, the schema and the data aren't real.*
>>
>> I want to analyze & run an algorithm on the comments text, then sort the
>> parent documents by it - *This would work with FunctionQuery, if I had
>> one
>> comment for each article and didn't use child documents*.
>> I tried to use the LeafReadContext to get the children, but with no luck.
>>
>> Is there any way to reach the children through FunctionQuery, or even use
>> something else to do what I want?
>>
>>
>> Thanks in advance,
>>
>> Dor
>>
>>
>>
>> --
>> View this message in context:
>> http://lucene.472066.n3.nabble.com/Sorting-documents-by-nested-child-docs-with-FunctionQueries-tp4209940.html
>> Sent from the Solr - User mailing list archive at Nabble.com.
>>
> 
> 
> 
> -- 
> Sincerely yours
> Mikhail Khludnev
> Principal Engineer,
> Grid Dynamics
> 
> <http://www.griddynamics.com>;
> <

> mkhludnev@

> >





--
View this message in context: 
http://lucene.472066.n3.nabble.com/Sorting-documents-by-nested-child-docs-with-FunctionQueries-tp4209940p4210646.html
Sent from the Solr - User mailing list archive at Nabble.com.


Sorting documents by nested / child docs with FunctionQueries

2015-06-05 Thread DorZion
Hey,

I'm using Solr 5.0.0 and I'm trying to sort documents with FunctionQueries.
The problem is that I'm trying to sort those documents with their child
documents elements.

Here is an example:
I have three documents, one is parent, the others are child documents
(_childDocuments_).

{
"id": "ArticleGuid",
"title" : "Sorting Child Documents",
"content_type": "article",
"_childDocuments_": [
  {
"id": "CommentGuid",
"content_type": "comment",
"text": "CommentText"
  },
  {
"id": "CommentGuid2",
"content_type": "comment",
"text": "CommentText"
  }
]
}
*
* This is just an example, the schema and the data aren't real.*

I want to analyze & run an algorithm on the comments text, then sort the
parent documents by it - *This would work with FunctionQuery, if I had one
comment for each article and didn't use child documents*.
I tried to use the LeafReadContext to get the children, but with no luck.

Is there any way to reach the children through FunctionQuery, or even use
something else to do what I want?


Thanks in advance,

Dor



--
View this message in context: 
http://lucene.472066.n3.nabble.com/Sorting-documents-by-nested-child-docs-with-FunctionQueries-tp4209940.html
Sent from the Solr - User mailing list archive at Nabble.com.