{"action":"created","issue":{"url":"https://api.github.com/repos/NightOwl888/BoboBrowse.Net/issues/9","labels_url":"https://api.github.com/repos/NightOwl888/BoboBrowse.Net/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/NightOwl888/BoboBrowse.Net/issues/9/comments","events_url":"https://api.github.com/repos/NightOwl888/BoboBrowse.Net/issues/9/events","html_url":"https://github.com/NightOwl888/BoboBrowse.Net/issues/9","id":58875607,"number":9,"title":"RangeStringFormatter","user":{"login":"dtosato","id":9847916,"avatar_url":"https://avatars.githubusercontent.com/u/9847916?v=3","gravatar_id":"","url":"https://api.github.com/users/dtosato","html_url":"https://github.com/dtosato","followers_url":"https://api.github.com/users/dtosato/followers","following_url":"https://api.github.com/users/dtosato/following{/other_user}","gists_url":"https://api.github.com/users/dtosato/gists{/gist_id}","starred_url":"https://api.github.com/users/dtosato/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dtosato/subscriptions","organizations_url":"https://api.github.com/users/dtosato/orgs","repos_url":"https://api.github.com/users/dtosato/repos","events_url":"https://api.github.com/users/dtosato/events{/privacy}","received_events_url":"https://api.github.com/users/dtosato/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-02-25T09:46:01Z","updated_at":"2015-03-03T09:19:08Z","closed_at":null,"body":"@NightOwl888 \r\nI am testing the `RangeStringFormatter` class, but it is not perfectly clear to me how to use it for different data type like `string`, `int`, or `double`.\r\nFor example, I made this test for strings, but the result is not as expected.\r\nCould you provide me some examples?   \r\n```c#\r\n[TestMethod]\r\npublic void CustomRangeStringFormattingTest()\r\n{\r\n\t//  Index.\r\n\tstring indexPath = @\"c:\\temp\\CustomRangeStringFormattingTest\";\r\n\t{\r\n\t\tusing (Lucene.Net.Store.Directory directory = FSDirectory.Open(new System.IO.DirectoryInfo(indexPath)))\r\n\t\t{\r\n\t\t\tstring category;\r\n\t\t\tusing (IndexWriter modifier = new IndexWriter(directory, new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30), true, Lucene.Net.Index.IndexWriter.MaxFieldLength.UNLIMITED))\r\n\t\t\t{\r\n\t\t\t\t{\r\n\t\t\t\t\tcategory = \"red\";\r\n\t\t\t\t\tDocument doc = new Document();\r\n\t\t\t\t\tdoc.Add(new Field(\"category\", category, Field.Store.YES, Field.Index.NOT_ANALYZED));\r\n\t\t\t\t\tmodifier.AddDocument(doc);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t{\r\n\t\t\t\t\tcategory = \"red\";\r\n\t\t\t\t\tDocument doc = new Document();\r\n\t\t\t\t\tdoc.Add(new Field(\"category\", category, Field.Store.YES, Field.Index.NOT_ANALYZED));\r\n\t\t\t\t\tmodifier.AddDocument(doc);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t{\r\n\t\t\t\t\tcategory = \"red\";\r\n\t\t\t\t\tDocument doc = new Document();\r\n\t\t\t\t\tdoc.Add(new Field(\"category\", category, Field.Store.YES, Field.Index.NOT_ANALYZED));\r\n\t\t\t\t\tmodifier.AddDocument(doc);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t{\r\n\t\t\t\t\tcategory = \"red\";\r\n\t\t\t\t\tDocument doc = new Document();\r\n\t\t\t\t\tdoc.Add(new Field(\"category\", category, Field.Store.YES, Field.Index.NOT_ANALYZED));\r\n\t\t\t\t\tmodifier.AddDocument(doc);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t{\r\n\t\t\t\t\tcategory = \"blue\";\r\n\t\t\t\t\tDocument doc = new Document();\r\n\t\t\t\t\tdoc.Add(new Field(\"category\", category, Field.Store.YES, Field.Index.NOT_ANALYZED));\r\n\t\t\t\t\tmodifier.AddDocument(doc);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t{\r\n\t\t\t\t\tcategory = \"blue\";\r\n\t\t\t\t\tDocument doc = new Document();\r\n\t\t\t\t\tdoc.Add(new Field(\"category\", category, Field.Store.YES, Field.Index.NOT_ANALYZED));\r\n\t\t\t\t\tmodifier.AddDocument(doc);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t{\r\n\t\t\t\t\tcategory = \"blue\";\r\n\t\t\t\t\tDocument doc = new Document();\r\n\t\t\t\t\tdoc.Add(new Field(\"category\", category, Field.Store.YES, Field.Index.NOT_ANALYZED));\r\n\t\t\t\t\tmodifier.AddDocument(doc);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t{\r\n\t\t\t\t\tcategory = \"yellow\";\r\n\t\t\t\t\tDocument doc = new Document();\r\n\t\t\t\t\tdoc.Add(new Field(\"category\", category, Field.Store.YES, Field.Index.NOT_ANALYZED));\r\n\t\t\t\t\tmodifier.AddDocument(doc);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t{\r\n\t\t\t\t\tcategory = \"green\";\r\n\t\t\t\t\tDocument doc = new Document();\r\n\t\t\t\t\tdoc.Add(new Field(\"category\", category, Field.Store.YES, Field.Index.NOT_ANALYZED));\r\n\t\t\t\t\tmodifier.AddDocument(doc);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t{\r\n\t\t\t\t\tcategory = \"green\";\r\n\t\t\t\t\tDocument doc = new Document();\r\n\t\t\t\t\tdoc.Add(new Field(\"category\", category, Field.Store.YES, Field.Index.NOT_ANALYZED));\r\n\t\t\t\t\tmodifier.AddDocument(doc);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// Field.\r\n\tstring field = \"category\";\r\n\r\n\t// Facet.\r\n\tIFacetHandler categoryFacetHandler = new RangeFacetHandler(field, new List<string> { \"[blue TO green]\", \"[red TO yellow]\" });\r\n\r\n\tICollection<IFacetHandler> handlerList = new IFacetHandler[] {  \r\n\t\tcategoryFacetHandler};\r\n\r\n\tusing (Lucene.Net.Store.Directory idx = FSDirectory.Open(new System.IO.DirectoryInfo(indexPath)))\r\n\t{\r\n\t\tusing (IndexReader reader = IndexReader.Open(idx, true))\r\n\t\t{\r\n\t\t\tusing (BoboIndexReader boboReader = BoboIndexReader.GetInstance(reader, handlerList))\r\n\t\t\t{\r\n\t\t\t\t// Request.\r\n\t\t\t\tBrowseRequest browseRequest = new BrowseRequest();\r\n\t\t\t\tbrowseRequest.Count = 10;\r\n\t\t\t\tbrowseRequest.Offset = 0;\r\n\t\t\t\tbrowseRequest.FetchStoredFields = true;\r\n\t\t\t\tbrowseRequest.Query = new MatchAllDocsQuery();\r\n\r\n\t\t\t\t// Selection. \r\n\t\t\t\tBrowseSelection sel = new BrowseSelection(field);\r\n\t\t\t\tbrowseRequest.AddSelection(sel);\r\n\r\n\t\t\t\t// FacetSpec.\r\n\t\t\t\tFacetSpec spec = new FacetSpec();\r\n\t\t\t\tspec.OrderBy = FacetSpec.FacetSortSpec.OrderValueAsc;\r\n\t\t\t\tspec.MaxCount = 10;\r\n\t\t\t\tbrowseRequest.SetFacetSpec(field, spec);\r\n\r\n\t\t\t\t// Browse.\r\n\t\t\t\tIBrowsable browser = new BoboBrowser(boboReader);\r\n\t\t\t\tBrowseResult result = browser.Browse(browseRequest);\r\n\r\n\t\t\t\t// Results.\r\n\t\t\t\tint totalHits = result.NumHits;\r\n\t\t\t\tBrowseHit[] hits = result.Hits;\r\n\t\t\t\tIDictionary<string, IFacetAccessible> facetMap = result.FacetMap;\r\n\t\t\t\tIFacetAccessible facets = facetMap[field];\r\n\r\n\t\t\t\t// Create a range string formatterly.\r\n\t\t\t\tRangeStringFormatter<string> formatter = new RangeStringFormatter<string>(\"[{0} TO {1}]\", \" [{0} ->\", \" {1}]\");\r\n\r\n\t\t\t\tBrowseFacet[] facetVals = facets.GetFacets().ToArray();\r\n\r\n\t\t\t\t// Check.\r\n\t\t\t\tAssert.AreEqual(2, facetVals.Count());\r\n\r\n\t\t\t\tstring formattedForDisplay1 = formatter.Format(facetVals[0].Value);\r\n\t\t\t\tstring formattedForDisplay2 = formatter.Format(facetVals[1].Value);\r\n\r\n\t\t\t\tAssert.AreEqual(new BrowseFacet(\"[blue -> green]\", 5), formattedForDisplay1);\r\n\t\t\t\tAssert.AreEqual(new BrowseFacet(\"[red -> yellow]\", 5), formattedForDisplay2);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/NightOwl888/BoboBrowse.Net/issues/comments/76911589","html_url":"https://github.com/NightOwl888/BoboBrowse.Net/issues/9#issuecomment-76911589","issue_url":"https://api.github.com/repos/NightOwl888/BoboBrowse.Net/issues/9","id":76911589,"user":{"login":"dtosato","id":9847916,"avatar_url":"https://avatars.githubusercontent.com/u/9847916?v=3","gravatar_id":"","url":"https://api.github.com/users/dtosato","html_url":"https://github.com/dtosato","followers_url":"https://api.github.com/users/dtosato/followers","following_url":"https://api.github.com/users/dtosato/following{/other_user}","gists_url":"https://api.github.com/users/dtosato/gists{/gist_id}","starred_url":"https://api.github.com/users/dtosato/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dtosato/subscriptions","organizations_url":"https://api.github.com/users/dtosato/orgs","repos_url":"https://api.github.com/users/dtosato/repos","events_url":"https://api.github.com/users/dtosato/events{/privacy}","received_events_url":"https://api.github.com/users/dtosato/received_events","type":"User","site_admin":false},"created_at":"2015-03-03T09:19:08Z","updated_at":"2015-03-03T09:19:08Z","body":"OK, now it is clear."}}