lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JT <handyrems...@gmail.com>
Subject Re: Questions developing custom functionquery
Date Fri, 11 Oct 2013 15:06:06 GMT
Hey Mikhail,

Thanks for responding.

Field: resourcename
Field-Type: org.apache.solr.schema.TextField
All 9 boxes checked (indexed, tokenized, stored).


I have various other fields (including MD5-checksums) in my Schema. When I
use a md5sum field (which is a <str> field, but doesn't have spaces,
forward slashes, etc.) The plugin I've written performs exactly as I've
expected.

I think the large part of my problem is that my "ValueSource" is being
instantianted as a the class "StrFieldSource". When you call getvalues on a
"StrFieldSource", you end up with a
DocTermsIndexDocValues<http://grepcode.com/file/repo1.maven.org/maven2/org.apache.lucene/lucene-queries/4.3.0/org/apache/lucene/queries/function/docvalues/DocTermsIndexDocValues.java#DocTermsIndexDocValues>.
Calling "getVal()" on a DocTermsIndexDocValues does some really weird stuff
that I really don't understand.
I assumed that calling ValueSource.getValues(...).strVal(int doc) would
simply return the "data" that my field corresponds to, but I don't think
that is true.


Its possible I'm going about this wrong and need to re-do my approach. I'm
just currently at a loss for what that approach is.



On Fri, Oct 11, 2013 at 2:48 AM, Mikhail Khludnev <
mkhludnev@griddynamics.com> wrote:

> Hello JT,
>
> what's is the field and fieldType definition for "resname" ?
> can't you check how '/some
> example/data/here/2013/09/12/
> testing.text
> ' is handled on analysis page in SolrAdmin?
>
>
> On Fri, Oct 11, 2013 at 4:53 AM, Richard Lee <rockiee281@gmail.com> wrote:
>
> > seems what u got is the terms other than the raw data. maybe u should
> check
> > the api docs for more details
> > 2013-10-11 上午3:56于 "JT" <handyremstad@gmail.com>写道:
> >
> > > I'm running into some issues developing a custom functionquery.
> > >
> > > My goal is to be able to implement a custom sorting technique.
> > >
> > > I have a field defined called resname, it is a single value str.
> > >
> > > Example: <str name="resname">/some
> > > example/data/here/2013/09/12/testing.text</str>
> > >
> > > I would like to do a custom sort based on this resname field.
> > > Basically, I would like to parse out that date there (2013/09/12) and
> > sort
> > > on that date.
> > >
> > >
> > > I've followed various tutorials
> > >    - http://java.dzone.com/news/how-write-custom-solr
> > >    -
> > >
> >
> http://www.supermind.org/blog/756/how-to-write-a-custom-solr-functionquery
> > >
> > >
> > > Im at the point where my code compiles, runs, executes, etc. Solr is
> > happy
> > > with my code.
> > >
> > > I have classes that inherit from ValueSorceParser and ValueSorce, etc.
> > I've
> > > overrode parse and
> > > instantiated my class with ValueSource
> > >
> > > public ValueSource parse(FunctionQParser fqp) {
> > >     return MyCustomClass(fqp.parseValueSource)
> > > }
> > >
> > > public class MyCustomClass extends ValueSource {
> > >     ValueSource source;
> > >
> > >     public MyCustomClass(ValueSource source) {
> > >         this.source = source;
> > >     }
> > >
> > >     public FunctionValues getValues(....) {
> > >        final FunctionValues sourceDV =
> > > source.getvalues(context,readerContext)
> > >        return new IntValues(this)
> > >             public int intVal(int doc) {
> > >                 //parse the value of "resname" here
> > >                   String value = sourceDV.strVal(doc);
> > >              ...more stuff
> > >              }
> > >        }
> > >    }
> > >
> > > The issue I'm running into is that my call to sourceDV.strVal(doc) only
> > > returns "part" of the field, not all of it. It appears to be very
> random.
> > >
> > > I guess my actual question is, how do I access / reference the EXACT
> RAW
> > > value of a field, while writing a functionquery.
> > >
> > > Do I need to change my ValueSource to a String?, then somehow lookup
> the
> > > field name while inside my getValues call?
> > >
> > > Is there a way to access the raw field data , when referencing it as a
> > > FunctionValues?
> > >
> > >
> > > Maybe I'm going about this totally incorrectly?
> > >
> >
>
>
>
> --
> Sincerely yours
> Mikhail Khludnev
> Principal Engineer,
> Grid Dynamics
>
> <http://www.griddynamics.com>
>  <mkhludnev@griddynamics.com>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message