fergiemcdowall / norch

A search server that can be installed with npm
655 stars 45 forks source link

Available fields a bit to "streamy"? #146

Closed eklem closed 4 years ago

eklem commented 7 years ago

Was thinking I should get a stream of objects back, but I get all the fields as one string. Is that correct?

http://test.klemespen.com:3030/availableFields

Indexed with latest search-index and latest norch server running.

eklem commented 7 years ago
*abvacidaromabitternesscodecolorcontainerSizecontainerTypecorkdescriptiondistrictfreshnessfullnessidimagemainCountrynamepricepricePerLiterproductSelectionproductTyperawMaterialstorablesugarsummarysweetnesstanninstastevintage
fergiemcdowall commented 7 years ago

Yes, it would probably be better if you could ask for an array. I'll look into it...

eklem commented 7 years ago

Doesn't need to be an array, but now it's just one long string without anything to split up on =)

fergiemcdowall commented 7 years ago

Have you tried doing it like this? https://github.com/fergiemcdowall/norch/blob/master/test/test.js#L72-L85

Either way- I think an array is a bit more accessible to people

eklem commented 7 years ago

Strange, this is the response I get from norch: screen shot 2017-03-03 at 12 55 59

eklem commented 7 years ago

Anyway =)

fergiemcdowall commented 7 years ago

Yes- this is a bit tricky because responses are streams. (I think) it is streaming the fieldnames and showing you the end result. An array would be easier

eklem commented 7 years ago

But, when thinking about it, I think you should keep it as a streaming interface but just wrap it as objects where the value is the string/field-name. One reason is that I now have two response processors. One for stream of objects and one for objects. Keeping it like that makes it clean.

Something like:

{"fieldname":"*"}
{"fieldname":"abv"}
{"fieldname":"acid"}
{"fieldname":"aroma"}
{"fieldname":"bitterness"}
{"fieldname":"code"}
{"fieldname":"color"}
{"fieldname":"containerSize"}
{"fieldname":"containerType"}
{"fieldname":"cork"}
{"fieldname":"description"}
{"fieldname":"district"}
{"fieldname":"freshness"}
{"fieldname":"fullness"}
{"fieldname":"id"}
{"fieldname":"image"}
{"fieldname":"mainCountry"}
...
fergiemcdowall commented 7 years ago

Yes- that makes sense

eklem commented 7 years ago

I'll look into fixing this in search-index-searcher

eklem commented 7 years ago

@fergiemcdowall I manage to re-write the output to be key/value as suggested above, but how do I get to define Content-Type = application/JSON?

To ask in a different way. How do you get the other endpoints like /search i.e. to return Content-Type = application/JSON?