I am working in a CF 9 environment with Solr collections. I have 7 of them that I'm working with, all are strictly PDFs. Using CFSEARCH, I'm not getting all of the documents that should be appearing in the results.
To give a specific example, the client has ten PDFs that contain the string 1386 somewhere in the body of the documents. But when using the search form and entering 1386, only 4 of them appear. The client is concerned that not all PDFs with 1386 are being displayed in search results.
I have been following (with great interest) David Faber's posts espousing the CFHTTP method of querying a Solr collection, but I'm running into snags trying to implement it.
One of the issues is that when using CFSEARCH, I'm using all four CUSTOM fields, and I'm also getting CONTEXT which will highlight the keyword. In the CFHTTP method, I'm not getting CONTEXT with highlighted keywords.
Also, I'm trying to deserialize JSON and convert that to a query object. But I keep getting the common error message about
attempting to reference a scalar variable array as a structure with members
Advice/suggestions greatly appreciated.
Related
First off, let me apologise for any mistakes, as this is my first post.
Now, for the actual issue:
I've coded a PHP script that handles MySQL Queries, including one that fetches all data from a certain table.
I made it so the final result is a JSON object, containing all rows from said table.
I also coded a Flutter class (Dart) that handles the request for the JSON object via the URL, and I got it to successfully log said JSON to the console.
However, when I use that data to show on an actual List of Widgets, this is what appears on screen:
Error Shown
Any ideas on how to fix this?
(For NDA reasons, I am not allowed to show the console logs.).
Any help is appreciated!
When I make GET HTTP call to Google Places API. (Example Call: "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&types=food&name=harbour&sensor=false&key=") ....
Under "results", inconsistent number of elements are returned. What is the base list of fields that will always be returned?
In the screenshot below, you can see how the array length count under "results" is different, counts are 11, 10, 10, and 8.
Screenshot below shows how one the JSON Arrays in the response has more elements than the other and the extra fields are circled in red.
I am confused here because I am trying to write code to parse the JSON and trying to understand which are the fields to expect? Missing fields in some arrays in the response is breaking my code.
Am I interpreting the API documentation incorrectly or Is this a bug that I should be filing with Google directly?
You might consider using logic that does not require any fields at all. Because the server is out of your control, it could return anything at any time (due to API changes, bugs, technical faults, etc.)
For example, in Sprockets I loop through whatever objects are returned and if the name matches something that I expect, then I process it. Otherwise the fields in my objects simply remain empty. You can see the top-level processing Java code in the PlacesResponse constructor.
It's not a bug, but documented behaviour. The Google Places API documentation says:
Each result within the results array may contain the following fields:
In other words, Google returns ratings, opening hours etc for places if it has them, but it will leave them out if it does not or the field is not relevant to the place (eg. you wouldn't have opening hours for an apartment complex or rate a train station). As #pushbit says, you have to parse accordingly and check whether each field was returned.
I have an ExpressionEngine site that I'm building with Bootstrap. It's a site for volunteers to find projects to help with. On the home page I have a modal with a form for them to select when they're available and what categories of jobs they're looking for. Then they can click submit and it'll go to a new page with filtered entries.
I don't know if this is possible using the GET method or POST method on the form. I've figured out how to use the GET method and get a query string into my URL but I don't know how to use that data to filter my entries on the entries page. Or would using POST and JSON be a better option? I don't know really how to implement either so any help would be great.
Thanks a lot!
It depends on how the information you would like to show is stored.
If you are using MySQL (a common RDMS), or any other form of SQL Database for that matter, the most common way is to send your GET query string (for example) to your server, have a sever-side language (such as PHP) handle that request by accessing your database, and then echo the result. This can be done synchronously, or with AJAX.
For example, the flow of everything might look like this:
User selects an option (say, "Gardening Projects").
JavaScript converts the value of that input option to a query string and sends an HTTP request using the GET method.
The destination of this request is "filter.php" (for example).
"filter.php" access your database using an SQL query, which searches for any entries in your database, say, having a tag of "gardening".
"filter.php" echos a statement with those entries (or, better yet, returns a JSON object)
JavaScript then parses the resultant JSON object into the DOM, which displays as a bunch of links in a result area that your user can click on.
The question you have about how to handle this is very broad, so I would recommend simply doing some Google searches or looking around this site for resources that show you how to set up databases, access those databases with possibly PHP/SQL, and maybe even use AJAX to return those results, etc.
To get you started (these are in no particular order):
AJAX Tutorial
PHP - JSON encode
SQL tutorial
jQuery AJAX
I got it figured out with some help from #JoshBeam. It turns out that I was trying to make it way more complicated than it actually is. Rookie mistake. In the end I just ended up using method=get in my form and the setting the action as the page with the filtered entries. I then used php to echo the inputs into my EE channel:entries tag.
One thing I still haven't figured out is how to make it so that my query string will combine values for matching names. Currently I have checkboxes for days of the week, each with name="day" and different values for each day. If there are multiple checked, my query string becomes example.com/?day=sun&day=mon when I'd rather have it as example.com/?day=sun&mon. So if anyone has any tips on that, I'd welcome them! I also wonder if there's a way to add pipes between each value when I echo them in my EE tag so that I can have multiples - e.g. {exp:channel:entries category="1|2|3"}. But I have really yet to Google either of these questions so I'll do that.
Thanks!
How to query ASP.NET Web API, but with a JSON POST, not GET URL?
The JSON object would contain the same data/filters/sort/paging as ODATA query or LINQ query. Can we deserialize the JSON object into something ODATA/LINQ can understand and then use that to easily execute on the DB (SQL Server)?
We've come across from articles about LINQ Expression Trees and ODataLib ODataUriParser, but still researching.
We want to expose an advanced search web service for a few tables or views in SQL Server, and want to keep it JSON and generic so many platforms can consume it. The consumer would need to pass in the search parameters, and we could probably create a data structure to contain it all, but are trying to also see if we can leverage some query model in ODATA or LINQ.
Any way to instead of putting the OData query in the URL, put it as a POSTed JSON object instead and have it continue to query the DB and return results normally? A couple of current reasons to put in POST are 1. can handle larger size and 2. instead of the consumer learning OData query syntax, they can just popular an search param object model.
Thanks in advance.
I am using Sencha GXT3 app for a html interface. Data is retrieved in json format from a REST service. How exactly do I fill a store with a single object for reading and later manipulating and saving?
This is not about lists of objects, but really a specific single json map which I want to load into a store.
Any help would be highly appreciated.
For Stores you have basically two choices list or tree. Right? GXT 3 store api
You say it's not a list so did you see the src of their json tree example
Personally for a single object, I use a list. I mean it's a list of size 1. json list example
Of those two examples, json tree example is easier to understand since it's not using a grid I think. There are tree grid examples too but none I immediately see with json.
This is for version 3. I see no reason why you'd want to start with 2 since 3 is much more similar to native gwt and you can mix 2 and three code (see their tutorial) until you get everything ported to the newer version. Just saying ...