Definitely looks like progress.  My guess is that there is a bug in the driver code which is causing an empty ID to be inserted at the beginning or end of the list, so when the Solr query is constructed, it ends up being invalid.  You might want to var_dump the return value of your getNewItems function to get a clue as to what’s going on.

 

Most likely explanations:

 

1.)    Off-by-one error in a loop somewhere.

2.)    Bad initialization of an array.

3.)    Bad data in the database or bad database query.

 

I don’t think it’s 1 or 2 because the code is pretty simple and looks correct to me…  but it’s always possible I’m missing something.

 

If it’s #3, you might need to add a “WHERE field IS NOT NULL” clause to your query, or else change the while loop to something like:

 

            while ($row = mssql_fetch_assoc($sqlStmt)) {

                if (!empty($row['BIBNO'])) {

                    $ids[] = array('id' => $row['BIBNO']);

                }

            }

 

- Demian

 

From: Trevor Dykstra [mailto:Trevor@infoxpert.com.au]
Sent: Tuesday, June 26, 2012 6:17 PM
To: Demian Katz; vufind-tech@lists.sourceforge.net
Subject: RE: getNewItems: Error when attempting display results

 

Thanks Demian,

I have put in the suggested change and think we are getting a step closer.

The error now displays:

 

An error has occurred

Unable to process query

Solr Returned: org.apache.lucene.queryParser.ParseException: Cannot parse 'id:( OR 1356 OR 7144 OR 12207 OR 15117 OR 20475 OR 24778 OR 26567 OR 28610 OR 28665 OR 28693 OR 28740 OR 32285 OR 39370 OR 44213 OR 44252 OR 45086 OR 46087 OR 47433 OR 50285 OR 56040 OR 63655 OR 63656 OR 63657 OR 63660 OR 63661 OR 63671 OR 63680 OR 63681 OR 63682 OR 63683 OR 63684 OR 63685 OR 63688 OR 63691 OR 63693 OR 63800 OR 63802 OR 63805 OR 63830 OR 63833 OR 63835 OR 63860 OR 63861 OR 63862 OR 63863 OR 63887 OR 63912 OR 63937 OR 63962 OR 63963 OR 63991 OR 63992 OR 63993 OR 64013 OR 64014 OR 64039 OR 64040 OR 64041 OR 64042 OR 64065 OR 64066 OR 64067 OR 64068 OR 64090 OR 64092 OR 64115)': Encountered " <OR> "OR "" at line 1, column 5. Was expecting one of: <NOT> ... "+" ... "-" ... "(" ... "*" ... <QUOTED> ... <TERM> ... <PREFIXTERM> ... <WILDTERM> ... "[" ... "{" ... <NUMBER> ... <TERM> ... "*" ...

RequestURI=/solr/biblio/select/

 

The debug shows:

Search options: Array

(

    [q] => id:( OR 1356 OR 7144 OR 12207 OR 15117 OR 20475 OR 24778 OR 26567 OR 28610 OR 28665 OR 28693 OR 28740 OR 32285 OR 39370 OR 44213 OR 44252 OR 45086 OR 46087 OR 47433 OR 50285 OR 56040 OR 63655 OR 63656 OR 63657 OR 63660 OR 63661 OR 63671 OR 63680 OR 63681 OR 63682 OR 63683 OR 63684 OR 63685 OR 63688 OR 63691 OR 63693 OR 63800 OR 63802 OR 63805 OR 63830 OR 63833 OR 63835 OR 63860 OR 63861 OR 63862 OR 63863 OR 63887 OR 63912 OR 63937 OR 63962 OR 63963 OR 63991 OR 63992 OR 63993 OR 64013 OR 64014 OR 64039 OR 64040 OR 64041 OR 64042 OR 64065 OR 64066 OR 64067 OR 64068 OR 64090 OR 64092 OR 64115)

    [rows] => 20

    [start] => 0

    [indent] => yes

    [hl.q] => id:( OR 1356 OR 7144 OR 12207 OR 15117 OR 20475 OR 24778 OR 26567 OR 28610 OR 28665 OR 28693 OR 28740 OR 32285 OR 39370 OR 44213 OR 44252 OR 45086 OR 46087 OR 47433 OR 50285 OR 56040 OR 63655 OR 63656 OR 63657 OR 63660 OR 63661 OR 63671 OR 63680 OR 63681 OR 63682 OR 63683 OR 63684 OR 63685 OR 63688 OR 63691 OR 63693 OR 63800 OR 63802 OR 63805 OR 63830 OR 63833 OR 63835 OR 63860 OR 63861 OR 63862 OR 63863 OR 63887 OR 63912 OR 63937 OR 63962 OR 63963 OR 63991 OR 63992 OR 63993 OR 64013 OR 64014 OR 64039 OR 64040 OR 64041 OR 64042 OR 64065 OR 64066 OR 64067 OR 64068 OR 64090 OR 64092 OR 64115)

    [fl] => score

    [facet] => true

    [facet.mincount] => 1

    [facet.limit] => 30

    [facet.field] => Array

        (

            [0] => topic_facet

            [1] => callnumber-first

            [2] => authorStr

            [3] => language

            [4] => genre_facet

            [5] => era_facet

            [6] => geographic_facet

            [7] => publishDate

        )

 

    [facet.prefix] =>

    [facet.sort] =>

    [hl] => true

    [hl.fl] => *

    [hl.simple.pre] => {{{{START_HILITE}}}}

    [hl.simple.post] => {{{{END_HILITE}}}}

)

 

POST: http://127.0.0.1:8090/solr/biblio/select/?q=id%3A%28+OR+1356+OR+7144+OR+12207+OR+15117+OR+20475+OR+24778+OR+26567+OR+28610+OR+28665+OR+28693+OR+28740+OR+32285+OR+39370+OR+44213+OR+44252+OR+45086+OR+46087+OR+47433+OR+50285+OR+56040+OR+63655+OR+63656+OR+63657+OR+63660+OR+63661+OR+63671+OR+63680+OR+63681+OR+63682+OR+63683+OR+63684+OR+63685+OR+63688+OR+63691+OR+63693+OR+63800+OR+63802+OR+63805+OR+63830+OR+63833+OR+63835+OR+63860+OR+63861+OR+63862+OR+63863+OR+63887+OR+63912+OR+63937+OR+63962+OR+63963+OR+63991+OR+63992+OR+63993+OR+64013+OR+64014+OR+64039+OR+64040+OR+64041+OR+64042+OR+64065+OR+64066+OR+64067+OR+64068+OR+64090+OR+64092+OR+64115%29&rows=20&start=0&indent=yes&hl.q=id%3A%28+OR+1356+OR+7144+OR+12207+OR+15117+OR+20475+OR+24778+OR+26567+OR+28610+OR+28665+OR+28693+OR+28740+OR+32285+OR+39370+OR+44213+OR+44252+OR+45086+OR+46087+OR+47433+OR+50285+OR+56040+OR+63655+OR+63656+OR+63657+OR+63660+OR+63661+OR+63671+OR+63680+OR+63681+OR+63682+OR+63683+OR+63684+OR+63685+OR+63688+OR+63691+OR+63693+OR+63800+OR+63802+OR+63805+OR+63830+OR+63833+OR+63835+OR+63860+OR+63861+OR+63862+OR+63863+OR+63887+OR+63912+OR+63937+OR+63962+OR+63963+OR+63991+OR+63992+OR+63993+OR+64013+OR+64014+OR+64039+OR+64040+OR+64041+OR+64042+OR+64065+OR+64066+OR+64067+OR+64068+OR+64090+OR+64092+OR+64115%29&fl=score&facet=true&facet.mincount=1&facet.limit=30&facet.field=topic_facet&facet.field=callnumber-first&facet.field=authorStr&facet.field=language&facet.field=genre_facet&facet.field=era_facet&facet.field=geographic_facet&facet.field=publishDate&facet.prefix=&facet.sort=&hl=true&hl.fl=%2A&hl.simple.pre=%7B%7B%7B%7BSTART_HILITE%7D%7D%7D%7D&hl.simple.post=%7B%7B%7B%7BEND_HILITE%7D%7D%7D%7D&wt=json&json.nl=arrarr

 

An error has occurred

 

Is the error due to the ID starting with "OR"? Any further suggestions?

 

Regards,

 

Trevor Dykstra

EvolvePlus Pty Ltd.

 

From: Demian Katz [mailto:demian.katz@villanova.edu]
Sent: Tuesday, 26 June 2012 10:46 PM
To: Trevor Dykstra; vufind-tech@lists.sourceforge.net
Subject: RE: getNewItems: Error when attempting display results

 

I think you need to do something more like this:

 

    public function getNewItems($page, $limit, $daysOld, $fundId = null)

    {

        $itemnew = array();

        $row = '';

 

        $sql = "select distinct STK_CAT_REF as BIBNO from STK_ITEM where STK_DATE_RECD >= GETDATE()-$daysOld ";

 

        try {

            $sqlStmt = mssql_query($sql);

            $ids = array();

            while ($row = mssql_fetch_assoc($sqlStmt)) {

                $ids[] = array('id' => $row['BIBNO']);

            }

            if (!empty($ids)) {

                return array('count' => count($ids), 'results' => $ids);

            }

            return null;

        }

        catch (PDOException $e) {

            return new PEAR_Error($e->getMessage());

        }

    }

 

I may have gotten some details slightly wrong, but this should result in a data structure closer to what VuFind expects – an array with “count” and “results” keys, with each entry of “results” containing an “id” key.

 

(I don’t claim that this data structure makes a whole lot of sense, by the way – it just happened to be shaped like that when I joined the project, and I haven’t wanted to disrupt the drivers by changing it; once again, apologies for any confusion).

 

- Demian

 

From: Trevor Dykstra [mailto:Trevor@infoxpert.com.au]
Sent: Tuesday, June 26, 2012 12:23 AM
To: vufind-tech@lists.sourceforge.net
Subject: [VuFind-Tech] getNewItems: Error when attempting display results

 

I'm having problems trying to get my ILS driver to display results when using the getNewItems function.

I have created a 'bare bones' getNewItems function to help me troubleshoot where the issue may be.

 

The error displayed in my browser after selecting "New Items" and the range of "Past 30 days" is:

 

An error has occurred

Unable to process query

Solr Returned: org.apache.lucene.queryParser.ParseException: Cannot parse 'id:()': Encountered " ")" ") "" at line 1, column 4. Was expecting one of: <NOT> ... "+" ... "-" ... "(" ... "*" ... <QUOTED> ... <TERM> ... <PREFIXTERM> ... <WILDTERM> ... "[" ... "{" ... <NUMBER> ... <TERM> ... "*" ...

 

RequestURI=/solr/biblio/select/

 

 

I have set debug=true which displays the following:

 

Notice: Undefined index: results in C:\vufind2\web\services\Search\NewItem.php on line 123

 

Search options: Array

(

    [q] => id:()

    [rows] => 20

    [start] => 0

    [indent] => yes

    [hl.q] => id:()

    [fl] => score

    [facet] => true

    [facet.mincount] => 1

    [facet.limit] => 30

    [facet.field] => Array

        (

            [0] => topic_facet

            [1] => callnumber-first

            [2] => authorStr

            [3] => language

            [4] => genre_facet

            [5] => era_facet

            [6] => geographic_facet

            [7] => publishDate

        )

 

    [facet.prefix] =>

    [facet.sort] =>

    [hl] => true

    [hl.fl] => *

    [hl.simple.pre] => {{{{START_HILITE}}}}

    [hl.simple.post] => {{{{END_HILITE}}}}

)

 

POST: http://127.0.0.1:8090/solr/biblio/select/?q=id%3A%28%29&rows=20&start=0&indent=yes&hl.q=id%3A%28%29&fl=score&facet=true&facet.mincount=1&facet.limit=30&facet.field=topic_facet&facet.field=callnumber-first&facet.field=authorStr&facet.field=language&facet.field=genre_facet&facet.field=era_facet&facet.field=geographic_facet&facet.field=publishDate&facet.prefix=&facet.sort=&hl=true&hl.fl=%2A&hl.simple.pre=%7B%7B%7B%7BSTART_HILITE%7D%7D%7D%7D&hl.simple.post=%7B%7B%7B%7BEND_HILITE%7D%7D%7D%7D&wt=json&json.nl=arrarr

 

 

    public function getNewItems($page, $limit, $daysOld, $fundId = null)

    {

        $itemnew = array();

        $row = '';

 

        $sql = "select distinct STK_CAT_REF as BIBNO from STK_ITEM where STK_DATE_RECD >= GETDATE()-$daysOld ";

 

        try {

            $sqlStmt = mssql_query($sql);

            if ($row = mssql_fetch_assoc($sqlStmt)) {

                $itemnew = array(

                    'count' => count($row),

                    'id' => $row['BIBNO']

                );

 

                return $itemnew;

            }

            return null;

        }

        catch (PDOException $e) {

            return new PEAR_Error($e->getMessage());

        }

    }

 

Any assistance would be appreciated.

 

Regards,

Trevor Dykstra.